How to access a display object on the stage in a class which is not a document class?
I am looking for a solution that doesn’t involve passing the stage as a parameter to the class.
One solution i always come across is using “TopLevel.as“. Is it a good method because as far as I have heard using global variables is not recommended because it might cause some problems while working on big projects.
All display objects have a addedToStage event dispatched when they are added to the display list, which gives you a reference to the stage. So you could do something like this:
There is no need to use the “Top Level” class, which is relying on global (ie: static) properties.