Blog Index
« Error launching remote program: device locked. | Main | Font embedding for Localization »
Tuesday
Feb232010

Don't call me yet!

If you have set your asset up in such a way that they contain movieclips in different keyframes and you want to go to a particular keyframe and in turn play the movieclip contained within it, you can't just do the following (here we assume there is movieclip called cartoon_mc inside keyframe cartoon):
// go to keyframe "cartoon"
gotoAndStop("cartoon");

// start animating cartoon_mc contained within keyframe "cartoon"
// this won't work because cartoon_mc will only come into existence
// in the next frame loop
cartoon_mc.gotoAndPlay("start");
Instead, you need to delay it by one frame so Flash has a chance to bring the movieclip into existence.  You can do the delay call by using TweenMax's delayedCall.
gotoAndStop("cartoon");
// Delay calling performAnimation method by one frame
TweenMax.delayedCall(1, performAnimation, null, true);

function performAnimation()
{
  cartoon_mc.gotoAndPlay("start");
}

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>