Blog Index

Entries in tweening (1)

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");
}