ActionScript Error #5000: The class ‘com.cjm.MyObj’ must subclass ‘flash.display.MovieClip’ since it is linked to a library symbol of that type.
Description:
This little error will pop up when you have used the linkage in your library and have not targeted the Class properly.
Fix:
Make sure that in your custom ActionScript Class that you have imported the MovieClip Class properly.
Bad Example:
package com.cjm{
public class MyObj extends MovieClip {
Good Example:
package com.cjm
{
import flash.display.MovieClip
public class MyObj extends MovieClip {
So import those classes properly to fix ActionScript Error #5000 and Happy Flashing
I have a rather complex project that I took over for someone who is no longer working for us. The problem is, his script has been rather confusing to follow and results in errors when rendered. The current errors I am working on troubleshooting is as follows;
1152: a conflict exists with inherited definition of threedify.im.MessageBox.title MovieClip in namespace public, and a 5000: The class ‘com.threedify.im.SceneSequence’ must subclass flash.display.MovieClip’ since its linked to a library symbol of that type. I can eliminate these errors by turning on the automatically declare stage instances but then I get 1056: Cannot create property notepad on com.threedify.im.MessageBox, 1034: Type coercion failed: cannot convert com.threedify.im::AppMain@1a5fd101 to Main and a 1009: Cannot access a property or method of a null object reference @ SaveAppButton…
Here are the documents in question:
SceneSequence.as
package com.threedify.im
{
import flash.display.MovieClip;
import flash.text.TextField;
public class SceneSequence extends flash.display.MovieClip {
public var chapterTitle:String;
public var subheading:String;
public var main:Main;
public var chapterTitleField:TextField;
public var subheadingField:TextField;
public function SceneSequence() {
x=205;
y=22;
chapterTitle = chapterTitleField.text;
subheading = subheadingField.text;
trace(“Scene Sequence Created for ” + chapterTitle + ” – ” + subheading);
trace(“parent is..?”);
}
}
}
MessageBox.as
package com.threedify.im{
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.*;
public class MessageBox extends MovieClip {
public var titleMovieClip:MovieClip;
public var messageBoxHitArea:MovieClip;
public function MessageBox() {
createMessage(“Notes”);
trace(“Message Box Created”);
}
public function clickHandler(e:MouseEvent) {
trace(“clicked”);
gotoAndPlay(currentFrame+1);
}
public function createMessage(buttonName:String=”test”){
//titleMovieClip.buttonTitle.text=buttonName;
//titleMovieClip.buttonTitle.selectable = false;
messageBoxHitArea.addEventListener(MouseEvent.CLIC K, clickHandler);
}
}
}
These are the two that seem to be resulting in errors. Any help on the matter would be greatly appreciated as I have been pulling out my hair trying to fix these.
I just went through my whole project and doing mainly two things got rid of all those 5000 subclass error messages and let my project compile properly again:
1. I changed each of my classes that extended Sprite so it extended MovieClip instead. I wanted to extend Sprite to avoid any extra MovieClip overhead for single-frame MovieClip symbols and that worked fine before, but once all of my classes were explicitly packaged, the Flash compiler got grumpy about it.
2. I prepended my package to most class names listed in the “Class” and “Base class” fields in the “Symbol Properties” or “Linkage Properties” windows (e.g., com.example.project.Class).
Along the way, I had to change the base class for some of the symbols in #2 from custom classes that were directly extended via ActionScript to flash.display.MovieClip. Most of this endeavor was just grunt work for the project’s library: changing clicking, right-clicking, changing text in properties windows, and clicking some more.
I hope some of this helps someone avoid some of the trouble I went through troubleshooting a long list of error messages that appeared all at once. By the way, the impetus for explicitly packaging an already-large and already-working project was to see if doing so might eliminate some errant behavior that manifests only when the SWF is loaded into another SWF.
I just packaged all of my classes for a previously clean-compiling project and now I am getting lots of these 5000 subclass error messages, including for the document class, which obviously isn’t even associated with a symbol in the library. Some classes are importing flash.display.MovieClip and extending it as MovieClip exactly as shown above and some are extending other classes; the Flash compiler seems inclined to complain either way.