Skip to content

Instantly share code, notes, and snippets.

@zwetan
Created May 29, 2015 03:33
Show Gist options
  • Save zwetan/e35436d785162b294138 to your computer and use it in GitHub Desktop.
Save zwetan/e35436d785162b294138 to your computer and use it in GitHub Desktop.
async, event and timers in redtamarin -- alpha quality
#!/usr/bin/as3shebang --
import shell.Program;
import shell.Runtime;
import flash.events.TimerEvent;
import flash.utils.Timer;
Program.atExit( function() { trace( "I'm out" ); } );
var timerHandler:Function = function( event:* ):void
{
trace( "TIMER" );
}
var timerCompleteHandler:Function = function( event:* ):void
{
trace( "TIMER_COMPLETE" );
Program.exit();
}
var mytimer:* = new Timer( 5000, 2 );
mytimer.addEventListener( TimerEvent.TIMER, timerHandler );
mytimer.addEventListener( TimerEvent.TIMER_COMPLETE, timerCompleteHandler );
mytimer.start();
Runtime.goAsync();
@zwetan
Copy link
Author

zwetan commented May 29, 2015

when you run this script you'll see a lot of debug output, it is normal

you should see

EventDispatcher ctor
EventDispatcher.ctor()
Timer ctor
add myself to the global timers [[object Timer]]
EventDispatcher.addEventListener()
EventDispatcher.addEventListener()
Timer.start()
Timer._start()
Runtime.goAsync()
starts loop
CoreEventLoop.start()
CoreEventLoop._loop()
tick() @ 5004
Timer.tick()
- _iteration = 1
Timer._timerDispatch()
Event ctor
Event.ctor(), type = timer
EventDispatcher.dispatchEvent()
EventDispatcher.dispatchEventFunction()
Event = [TimerEvent type="timer" bubbles=false cancelable=false eventPhase=0]
type = timer
arr = function Function() {} (1)
[object Timer] dispatching event timer #0 to function Function() {}
TIMER
[object Timer] finished dispatching event timer #0 to function Function() {}
- _repeatCount = 2
tick() @ 10013
Timer.tick()
- _iteration = 2
Timer._timerDispatch()
Event ctor
Event.ctor(), type = timer
EventDispatcher.dispatchEvent()
EventDispatcher.dispatchEventFunction()
Event = [TimerEvent type="timer" bubbles=false cancelable=false eventPhase=0]
type = timer
arr = function Function() {} (1)
[object Timer] dispatching event timer #0 to function Function() {}
TIMER
[object Timer] finished dispatching event timer #0 to function Function() {}
- _repeatCount = 2
Timer.stop()
Event ctor
Event.ctor(), type = timerComplete
EventDispatcher.dispatchEvent()
EventDispatcher.dispatchEventFunction()
Event = [TimerEvent type="timerComplete" bubbles=false cancelable=false eventPhase=0]
type = timerComplete
arr = function Function() {} (1)
[object Timer] dispatching event timerComplete #0 to function Function() {}
TIMER_COMPLETE
I'm out

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