I made this class and I put it in the same package of Timeline.as (the Document Class):
package {
import flash.utils.Timer;
import flash.events.TimerEvent;
public class Counter2 extends Timer {
public function Counter2(delay:Number, repeatCount:int=0) {
super(delay, repeatCount);
super.addEventListener(TimerEvent.TIMER, timerHandler);
}
public override function start():void {
super.start();
}
public override function stop():void {
super.stop();
}
public function timerHandler(evt:TimerEvent) {
trace(evt.target.currentCount);
}
}
}
This class is instanciated in Timeline.as constructor. Is there any way to reference Timeline(root) from this class? And, if so, how?
Thanks!
The static Stage object is only accessible to objects on the display list. Try creating a public method in your custom timer class & use that to pass (and store) a reference to the stage.... like so:
Document class (or another object currently on the display list):
Your custom class (not in the display list: