I am trying to dispatch event every second from Mytimer class and catch the event from Main class. I've declared variable "sus" as integer = 10. I have nothing so far, no output, nothing. Some help please!
This is Mytimer.as
private function onUpdateTime(event:Event):void
{
nCount--;
dispatchEvent(new Event("tickTack", true));
//Stop timer when it reaches 0
if (nCount == 0)
{
_timer.reset();
_timer.stop();
_timer.removeEventListener(TimerEvent.TIMER, onUpdateTime);
//Do something
}
}
And in Main.as I have:
public function Main()
{
// constructor code
_timer = new MyTimer ;
stage.addEventListener("tickTack", ontickTack);
}
function ontickTack(e:Event)
{
sus--;
trace(sus);
}