14May
Timer Events with Function Parameters
No commentsWithin the Adobe documentation I found this Constructor that exemplifies the usage of the Timer method and the ability to pass in parameters to the function that is called by the timer. I edited this slightly, but here it is:
package {
import flash.display.Sprite;
import flash.utils.*;
public class IntervalsWithParameters extends Sprite {
private var intervalDuration:Number = 1000; // duration between intervals, in milliseconds
private var intervalId:uint;
private var counter:uint = 0;
private var stopCount:uint = 2;
public function IntervalsWithParameters() {
intervalId = setInterval(myRepeatingFunction, intervalDuration, "Hello", "World");
}
public function myRepeatingFunction():void {
trace(arguments[counter]);
counter++;
if(counter == stopCount) {
trace("Clearing Interval");
clearInterval(intervalId);
}
}
}
}
Categories: Actionscript 3, Timer Methods
Wednesday, May 14th, 2008 at 10:59 am and is filed under Actionscript 3, Timer Methods. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.