/ Published in: ActionScript 3
Flash's Timer Class requires two parameters. The first is the delay (in milliseconds), the second is the amount of times you want the delay to fire.
Expand |
Embed | Plain Text
var timer:Timer = new Timer(1000, 2); timer.addEventListener(TimerEvent.TIMER, blah); timer.start(); function blah(e:TimerEvent):void{ trace("Times Fired: " + e.currentTarget.currentCount); trace("Time Delayed: " + e.currentTarget.delay); }
Comments
Subscribe to comments
You need to login to post a comment.

When e.currentTarget.currentCount = 1 i would like to reset it again to 0. How can i do this? I tried e.currentTarget.currentCount.reset(); and some kind like that ... but it won't work, any ideas?
What are you trying to accomplish? Maybe there's another way to solve your problem?
you can establish a variable separate from the currentCount that increases by one each time the counter blah function is hit.
var timer:Timer = new Timer(1000, 2); var currentIndex:Number = 0; timer.addEventListener(TimerEvent.TIMER, blah); timer.start();
function blah(e:TimerEvent):void{ currentIndex++; if(currentIndex >= 10){ currentIndex = 0; } trace("Times Fired: " + e.currentTarget.currentCount); trace("Time Delayed: " + e.currentTarget.delay); }
Very cool! ccpotter, thanks for sharing.
always good to have a place to copy and paste from, thanks!
@bengoevaerts - you can call Timer.reset() as mentioned here http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/utils/Timer.html
Good luck,
Sidney de Koning