In ActionScript 2, it was possible to access the stage from anywhere, through the static Stage class. With ActionScript 3, we lost that ability, and only display objects were permitted access—and only once they had been added to the stage.
To help you get access wherever you need it, CASA Lib for AS3 has a utility class called
StageReference in the
org.casalib.util package. It’s a static class that lets you keep track of the stage (or multiple stages if you’re developing an AIR app with multiple windows). Here’s how we recommend using it.
In the constructor of your main document class, just call this line of code:
Now, throughout your entire site or application, you can get access to the stage reference from anywhere by using this line of code: