Saturday, August 08, 2009

MovieClip Timeline Control

Controlling the main timeline from a movie clip should be as easy as this:

function goHome(e:MouseEvent):void {
this.gotoAndStop("one");
}

But it doesn't work. Turns out that you can't do this in AS3 because root, this, and parent refers to display objects that don't have multiple frames. You need to encase the script with the MovieClip object as follows:

function goHome(e:MouseEvent):void {
MovieClip(root).gotoAndStop("one");
}

Strange, but true.

Labels: , , ,