Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@simongregory
Created October 8, 2010 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simongregory/616922 to your computer and use it in GitHub Desktop.
Save simongregory/616922 to your computer and use it in GitHub Desktop.
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();
}
}
}
@simongregory
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment