This content has been marked as final. Show 3 replies
you must cast that display object as a dynamic class - for example, a movieclip:
Thanks for the response. Is this the best approach? Are there other solutions? Depending on which frame its on, the result is null. On my main timeline I have:
var st:String = "HELLO";
trace ("FROM ROOT IN CLIP -- " + sq.st02);
I also have a MC called sq and on its (sq) timeline I have the following on the first frame:
var st02:String = "st02 Declared in clip CLIP";
trace ("FROM CLIP IN ROOT -- " + MovieClip(root).st);
This is the output:
FROM ROOT IN CLIP -- null
FROM CLIP IN ROOT -- HELLO
If I move the Actionscript keyframe on main timeline from frame 1 to 2 the output is:
FROM CLIP IN ROOT -- null
FROM ROOT IN CLIP -- st02 Declared in clip CLIP
Does AS3 have a new (and better) means of communicating between MCs and the main timeline?
no, that issue would occur in as2, too. the code in frame 1 of the root timeline executes before the code in the first frame of sq. so, you're trying to access sq.st02 (from the root timeline) before it exists.
there are a few ways to handle that but as3 has a specific event (RENDER) that should allow you to delay execution of that trace() function until sq has been instantiated and its code in frame 1 executed.