Actionscript3 what's the point of addFrameScript

I want to ask about addFrameScript.

addFrameScript(0, frame1);   

      

what does this script mean? why is it 0?

Can I replace 0 with another number or word?

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

}// end function

      

If someone can help me understand?

+3


source to share


2 answers


This undocumented method is used to call a function when the playhead MovieClip

reaches a given frame, in this case 1st frame, 0

(0 based index). Of course, you are limited by the number of frames available; for example, to add a script to you the last frame you have to 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 a Flash development tool.

+5


source


A frame is a temporary fragment in a flash player. So if your fps is set to 12 frames per second, the script in that frame will be drawn attention (executed) for 1/12 of a second.

addFrameScript

hardly documented, perhaps to discourage developers from using it. So basically, in your code, you initialize the timer class and manually manage your timing chunks.



Frames are again represented as a zero-indexed array, with a set of executable files called a script frame. So when you add the framecript yourself, you are just doing what the constructor of the Frame class can do (internally), if you put it in the as3 panel of the frame in the IDE.

In short, addFrameScript(0, frame1);

is somthing in parallel with frameScripts[0] = frame1;

, where frameScripts can be an internal array.

0


source







All Articles