Hi,
Guys i have been trying to figure our the dispatchEvent system in as3. But am just not able to wrap my head around it. So can someone please explain and give me an example on how to dispatch custom events?
for eg: Here i just want to disptach event every 100ms and the event should give me the value of “a” . So can someone help me out?
package com
{
import flash.utils.Timer;
import flash.events.TimerEvent
import flash.events.EventDispatcher
/**
* ...
* @author
*/
public class test
{
private var a:Number = 0
public function test()
{
}
private function main_loop(e:TimerEvent)
{
a++
//trace(a)
}
public function goOn()
{
var newTimer:Timer = new Timer(100);
newTimer.addEventListener(TimerEvent.TIMER, main_loop);
newTimer.start ();
}
}
}