Flash CS,外部类的引用根

Flash CS,外部类的引用根,flash,reference,document-class,Flash,Reference,Document Class,我创建了这个类,并将它放在Timeline.as(Document类)的同一个包中: 此类在Timeline.as构造函数中实例化。 有没有办法从这个类中引用时间轴(根)?如果是的话,怎么做 谢谢 静态阶段对象仅可由显示列表上的对象访问。尝试在自定义计时器类中创建一个公共方法,并使用该方法传递(和存储)对stage的引用。。。。像这样: 文档类(或当前显示列表上的其他对象): 自定义类(不在显示列表中): package { import TestDependency; impo

我创建了这个类,并将它放在Timeline.as(Document类)的同一个包中:

此类在Timeline.as构造函数中实例化。 有没有办法从这个类中引用时间轴(根)?如果是的话,怎么做


谢谢

静态阶段对象仅可由显示列表上的对象访问。尝试在自定义计时器类中创建一个公共方法,并使用该方法传递(和存储)对stage的引用。。。。像这样:

文档类(或当前显示列表上的其他对象):

自定义类(不在显示列表中):

package {
    import TestDependency;
    import flash.display.MovieClip;

    public class Main extends MovieClip
    {
        public var td:TestDependency;

        function Main() {
            td = new TestDependency(1000);
            td.bindToStage(this.stage);
        }
    }
}
package {
    import flash.display.Stage;
    import flash.utils.Timer;
    public class TestDependency extends Timer
    {
        private var stageRef:Stage;

        function TestDependency(delay) {
            super(delay);
        }

        public function bindToStage($stageRef:Stage)
        {
            this.stageRef = $stageRef;
            trace(this.stageRef.stageWidth);
        }
    }
}
package {
    import flash.display.Stage;
    import flash.utils.Timer;
    public class TestDependency extends Timer
    {
        private var stageRef:Stage;

        function TestDependency(delay) {
            super(delay);
        }

        public function bindToStage($stageRef:Stage)
        {
            this.stageRef = $stageRef;
            trace(this.stageRef.stageWidth);
        }
    }
}