0
votes

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 methods on frame 4 when you are on frame 3.

2

2 Answers

1
votes

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();
0
votes
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