public
Created

  • Download Gist
TimerTest.as
ActionScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
package
{
 
import flash.display.Sprite;
import flash.events.TimerEvent;
import flash.text.TextField;
import flash.utils.Timer;
import flash.utils.getTimer;
 
public class TimerTest extends Sprite
{
 
public function TimerTest()
{
setup();
}
 
//public const MAX_INT:int = 2147483647;
private var _count:int = int.MAX_VALUE;
 
private var _startTime:int;
private var _inc:int = 2;
private var _timer:Timer;
private var _tf:TextField;
 
public function setup():void
{
_startTime = getTimer();
 
_tf = new TextField();
_tf.width = 500;
_tf.x = 10;
_tf.y = 10;
 
_tf.text = "Searching for valid Timer delay, down from " + _count +
" in increments of " + _inc;
 
addChild(_tf);
 
continueCountdown();
}
 
protected function continueCountdown():void
{
_timer = new Timer(_count,1);
_timer.addEventListener(TimerEvent.TIMER_COMPLETE,
onTimer,
false, 0, true);
_timer.start();
 
_count -= _inc;
}
 
protected function onTimer(event:TimerEvent):void
{
event.target.removeEventListener(event.type, arguments.callee);
 
var runningTime:int = getTimer() - _startTime;
 
_tf.text = "On Timer fired with a delay of " + event.target.delay +
" milliseconds it has been " + runningTime + " milliseconds" +
" since startup.";
 
_timer.stop();
_timer = null;
 
continueCountdown();
}
 
}
 
}

The following values represent the last value in passed to the timer that failed and executed immediately.

2147196983
2147275487
2147067837
2147026775
2146978533
2147208113
2147038535
2147483525
2147087787
2147015447

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.