actionscript3 whats the point of addFrameScript

六月ゝ 毕业季﹏ 提交于 2019-12-01 05:26:23

问题


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?


回答1:


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.




回答2:


A frame is a time slice in flash player. So if your fps is set to 12 fps, the script in that frame will be given attention (executed) for 1/12th of a second.

addFrameScript is hardly documented, perhaps to discourage it's use by developers. So basically, in code you initialize the timer class & manually manage your time slices.

Frames are again represented as a zero indexed array, with collection of executable called the frame script. So when you add the framescript yourself, you are simply doing what constructor of the Frame Class (internally) might do if you put it on the as3 panel of the frame in IDE.

In short, addFrameScript(0, frame1); is somthing in parallel to frameScripts[0] = frame1; where frameScripts could be an internal array.



来源:https://stackoverflow.com/questions/14536357/actionscript3-whats-the-point-of-addframescript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!