Copy link to clipboard
Copied
I have buttons, that when clicked will create an instance in one of 3 movie clips within a movie clip.
For instance, this works just fine:
b_IF_4G5_TOP.addEventListener(MouseEvent.CLICK, b_IF_4G5_TOP_add);
function b_IF_4G5_TOP_add(event:MouseEvent):void
{
var b:MovieClip = new IF_4G5_TOP();
b.name = "IF_4G5_TOP";
layout.substrate.addChild(b);
}
but this does not:
p_conn_h.addEventListener(MouseEvent.CLICK, p_conn_h_add);
function p_conn_h_add(event:MouseEvent):void
{
var b:MovieClip = new PC_H(); <- This line produces this error: 1180: Call to a possibly undefined method PC_H.
b.name = "p_conn";
layout.connectors.addChild(b);
}
Which is odd, because as you can see in the first example, I have not "defined" var b:MovieClip = new IF_4G5_TOP();
Both objects exist in the library, are movie clips, both targets and objects are accuratley named and exist.
Am I missing something obvious? Thanks in advance for your help.
Check the PC_H movieclip name have given as linkage name, if yes then check have you given any instance name for the same movieclip. If yes remove the instance name.
or try to change the movieclip name,
var b:MovieClip = new PC_H();
Copy link to clipboard
Copied
looks good, but I'd try duplicating the bad clip and renaming/classifying it to see if that helps
Copy link to clipboard
Copied
Check the PC_H movieclip name have given as linkage name, if yes then check have you given any instance name for the same movieclip. If yes remove the instance name.
or try to change the movieclip name,
var b:MovieClip = new PC_H();
Copy link to clipboard
Copied
Thanks for the suggestions, guys.
I did try renaming the movieclips, no success.
The movieclips that work fine, like IF_4G5_TOP have no as linkage or anything. The code simply places a copy of the movieclip from the library onto the stage within its target movieclip.
I even tried to change their target to the same target as the ones that work:
layout.connectors.addChild(b);
to
layout.substrate.addChild(b);
But no go...
Why do you suppose an identical function would work in one case, but throw errors in another? It's seemingly irrational inconsistencies like this that are so frustrating about actionscript.
Any ideas? Thanks again.
Copy link to clipboard
Copied
I did what you suggested and gave the movieclip PC_H the AS Linkage name PC_H and now it works, the button now places a copy in the target movieclip, but I have one question: Why?
I have no AS Linkage names for the previous movieclips that work... why would I need to do something different for similar movieclips?
How would anyone know to do that from the cryptic and maddening error messages Flash offers?
Like I said, irrational and inconsistent are words that describe actionscript programming all too often...
Thanks for your help, I appreciate it very much!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now