开发者

Flash AS2 Call function from Next Frame

How to call AS2 method from NextFrame(or any other frame) in Flash?

Say you have Action Frame on frame 3, and another one on frame 4, how do you call metho开发者_Python百科ds on frame 4 when you are on frame 3.


You cant call a function you haven't defined yet:

To call a function, that function's definition must be in a frame that the playhead has reached. (AS2 docs)

Best to define your functions early on (say in frame 1), then you can use them at any later point in the timeline.

in frame 1:

function hello(){
    trace("Hello world!");
};

function bye(){
     trace("Goodbye, cruel world!");
};

in frame 3:

hello();

in frame 4:

bye();


var xx = 100;
var yy = 40;
var i = 17;

this.onEnterFrame = function(){
    if((_currentFrame > i)&&(_currentFrame < 84)){
        i += 2;
        xx += 10;
        addSparkles(xx,yy,7,100,40);
    }
}

This will run addSparkles function every second frame, starting 17th, ending 53rd

this snippet works in nested movie clip timelines as well

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜