I'm trying to dynamically change the text on the main stage from a sub class, but I cannot figure out how to do it. I can change the field text from the main class just fine by using myTextArea.text = "Blarg", but I'm stumped for doing it from a sub class and google hasn't helped.
My application structure is similar to:
//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";
}
}
}
I'm sure the solution is simple, but I just can't wrap my head around it and I would love your help!