Actionscript 3 从子类Flash AS3动态更改文本字段?

Actionscript 3 从子类Flash AS3动态更改文本字段?,actionscript-3,flash,oop,class,Actionscript 3,Flash,Oop,Class,我试图从一个子类动态地更改主阶段上的文本,但我不知道如何做。我可以使用myTextArea.text=“Blarg”很好地更改主类中的字段文本,但是从子类中更改字段文本让我很难堪,谷歌也没有帮助 我的应用程序结构类似于: //Main class file package { import flash.display.Sprite; import flash.events.Event; import flash.display.Stage; public cl

我试图从一个子类动态地更改主阶段上的文本,但我不知道如何做。我可以使用myTextArea.text=“Blarg”很好地更改主类中的字段文本,但是从子类中更改字段文本让我很难堪,谷歌也没有帮助

我的应用程序结构类似于:

//Main class file
package {

    import flash.display.Sprite;
    import flash.events.Event;
    import flash.display.Stage;

    public class Main extends Sprite {

        static public var mainStage:Stage;

        public function Main() {
            if (stage) stageLoader();
            else addEventListener(Event.ADDED_TO_STAGE, stageLoader);
        }

        private function stageLoader() {
            mainStage = this.stage;
            removeEventListener(Event.ADDED_TO_STAGE, stageLoader);

            //This is working just fine
            myTextArea.text = "Blarg";
         }

    }

}

//Sub class
package {

    import flash.display.Sprite;

    public class OtherClass extends Sprite {

        public function OtherClass() {
            //This throws "Access of undefined property myTextArea" error
            myTextArea.text = "Blarg";
        }

    }

}

我相信这个解决方案很简单,但我就是想不通,我很想得到你的帮助

当我创建需要指向主时间轴的链接的类时,我会将范围作为参数传递给构造函数。大概是这样的:

package {

  import flash.display.Sprite;

  public class OtherClass extends Sprite {

      public function OtherClass(_path) {
            //This throws "Access of undefined property myTextArea" error
       _path.myTextArea.text = "Blarg";
      }

  }
}

然后从你的主课:

var _otherClass = new OtherClass(this);

一个很好的,简单的解决我问题的方法。非常感谢!:)