actionscript3 whats the point of addFrameScript

Intan Mega picture Intan Mega · Jan 26, 2013 · Viewed 7.9k times · Source

I want to ask about addFrameScript.

addFrameScript(0, frame1);   

what is this script means? why its 0?

is it possible to replace 0 with other number or word?

public function try()
{
    addFrameScript(0, frame1);
    return;

}// end function

If someone can help me to understand?

Answer

Antoine Lassauzay picture Antoine Lassauzay · Jan 26, 2013

This undocumented method is used to invoke a function when a MovieClip instance playhead reaches the given frame, in that case the 1st frame, 0 (0-based index). Your are of course limited to the available number of frames ; for instance, to add a script you the last frame, you would use :

mc.addFrameScript(mc.totalFrames-1, lastFrameReached);

function lastFrameReached():void {
    trace("stopping the animation");
    mc.stop();
}

Just think of it as a frame with some code inside the Flash authoring tool.