Desmond Liang
Desmond Liang

Reputation: 2310

flash 8 + setTimeout problem

I have to hand off a Flash file to a client that use Flash 8, so I am using ActionScript 2 here. I am trying to create a firework effect that consist five fireballs (all instances of the same movieclip) that explode at different time using setTimeout. Here is the code:

setTimeout( playFirework(fireball1), 3500 );
setTimeout( playFirework(fireball2), 4500 );
setTimeout( playFirework(fireball3), 4500 );
setTimeout( playFirework(fireball4), 5500 );
setTimeout( playFirework(fireball5), 5500 );

function playFirework(mcFirework){
    mcFirework.gotoAndPlay("start")
}

The delay doesn't seen to be happening. All fireballs start at the same time. Any idea?

Upvotes: 1

Views: 3328

Answers (1)

John Giotta
John Giotta

Reputation: 16984

The syntax is

setTimeout( callback, delay, argument)

So you want

setTimeout(playFirework, 3500, fireball1);

http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00000602.html

Upvotes: 3

Related Questions