Trust Me, AS3, It’s a MovieClip

November 29th, 2007
Flash ActionScript 3.0

This topic came up when someone asked me how (if it was possible) to instruct one movie clip to start playing after another has stopped.  For example, the main timeline does its thing, humming along, when it suddenly comes to a keyframe that contains a nested movie clip.  A simple stop() action in that keyframe tells the main timeline to rest where it is, and the nested movie clip starts playing on its own.  When the nested clip hits the last frame of its own timeline … that’s when the main timeline needs to start moving again.  How to do that?

In my reply, I said there were a number of possible ways.  You could set up a loop, for example — MovieClip.onEnterFrame (AS2) or Event.ENTER_FRAME (AS3), maybe setInterval() (AS2) or the Timer class (AS3) — and in that loop, check the current frame of the nested movie clip against the number of its total frames.  In AS2, that would be a comparison of _currentframe to _totalframes; in AS3, currentFrame to totalFrames.  When the former equals the latter, invoke MovieClip.play() on the main timeline and quit the loop.

But much easier than that, and less processor intensive, is simply to put a keyframe script in the last frame of the nested movie clip, telling its parent (the main timeline) to play.  In AS2, that would be this._parent.play();.  In AS3, this.parent.play(); (no underscore on parent).  Ah, but there lies a problem.  The AS3 version, which is technically correct, causes a compiler warning:  1061: Call to a possibly undefined method play through a reference with static type flash.display:DisplayObjectContainer.  What on earth?  Keep reading »

How to Pause and Loop the Timeline in Flash CS3 (AS3)

November 26th, 2007

And the Winner of Essential ActionScript 3.0 is …

November 15th, 2007

How to Load External Flash Video (FLV) Files (AS3)

November 13th, 2007

Chance to Win a Free Copy of Moock’s Essential ActionScript 3.0

October 25th, 2007

How to Play Flash Video Files (FLV) Sequentially

October 19th, 2007

Foundation Flash CS3 Gets a Second Print Run

October 19th, 2007

How to Use Flash Video (FLV) Cue Points

October 9th, 2007

How to Retrieve FlashVars Data in ActionScript 3.0

September 25th, 2007

Canton Gives Foundation Flash CS3 for Designers a Thumbs Up

August 31st, 2007