mhulse
June 12th, 2009, 06:54 PM
Hi!
I am slowly learning my way around AS3...
Quick question:
How do tell my parent class to wait for a subclass Timer finish event?
Here is my "Timing" subclass:
package com.site.peel {
import flash.utils.Timer;
import flash.events.TimerEvent;
public class Timing {
private var _period:uint;
public function Timing(t:uint = 10000):void {
_period = t;
init();
};
private function init():void {
var flashTimer:Timer = new Timer(_period);
flashTimer.addEventListener(TimerEvent.TIMER, onTime);
flashTimer.start()
};
private function onTime(evt:TimerEvent):void {
trace('Timer has completed...');
};
};
};My parent class calls the above like so:
...
...
...
private var _timing:Timing;
...
...
_timing = new Timing();
...
...
...
I am able to see the trace "Timer has completed...", but I am not sure how to tell my parent class that the subclass has finished the timer.
Additionally, once I am done using the Timing subclass, how do I destroy the event listener from the parent class? Should I just create another method in the Timing class that removes the event listener, and call it like so:
_timing.removeListener();
Does that makes sense?
I would love a little guidance. :)
Many TIAs!
Cheers,
Micky
I am slowly learning my way around AS3...
Quick question:
How do tell my parent class to wait for a subclass Timer finish event?
Here is my "Timing" subclass:
package com.site.peel {
import flash.utils.Timer;
import flash.events.TimerEvent;
public class Timing {
private var _period:uint;
public function Timing(t:uint = 10000):void {
_period = t;
init();
};
private function init():void {
var flashTimer:Timer = new Timer(_period);
flashTimer.addEventListener(TimerEvent.TIMER, onTime);
flashTimer.start()
};
private function onTime(evt:TimerEvent):void {
trace('Timer has completed...');
};
};
};My parent class calls the above like so:
...
...
...
private var _timing:Timing;
...
...
_timing = new Timing();
...
...
...
I am able to see the trace "Timer has completed...", but I am not sure how to tell my parent class that the subclass has finished the timer.
Additionally, once I am done using the Timing subclass, how do I destroy the event listener from the parent class? Should I just create another method in the Timing class that removes the event listener, and call it like so:
_timing.removeListener();
Does that makes sense?
I would love a little guidance. :)
Many TIAs!
Cheers,
Micky