In a project, I need to pass in a DisplayObject to a container in a specified frame of a MovieClip. (for example a “container” instance at Frame 15)
I thought it should be just okay with this code:
**trace(mc.currentFrame);** // Output 1 - we are at the first frame of this mc. **mc.gotoAndStop(15);** // Go to the frame where a container is made ready // There is a container which has an instance name // of "container" in this frame. **trace(mc.currentFrame);** // Output: 15 - [COLOR="Red"]That means the mc has reached the right frame already[/COLOR]. **trace(mc.getChildByName("container"));** // **null** - why it's null? - or why it's "container" still NOT READY? How do I know when it's ready? I can use a Timer or somewhat to hack this logic but that's also a very bad logic.
Any tips for this situation? Thanks in advance!
Update: More information on this topic:
Just now I set up a Timer to track the “container” existence. The timer is set up as soon as the gotoAndStop is invoked. like this:
mc.gotoAndStop(15); var timer:Timer = new Timer(1,1);
If the timer delay is set to 1, the container is still not available, but if it’s set to 100, it’s okay. Then I make this delay bigger and bigger, the threshold value is 25. (My FPS is 30)