The stage property and the display list
- Posted by kajyr on January 9th, 2009
- Comment now »
In Actionscript, the stage object is referenced by the DisplayObject.stage property. I use it alot, for example, to center elements on the screen, but as we read in the api reference,
If a display object is not added to the display list, its stage property is set to null.
this can be uncomfortable when you want to position something before attaching it, for any reason, or if you want a control object to operate on some stage property (fullscreen, for example).
So to avoid this, I usually add a static property to my Document Class, let’s call it staticStage:
GeSHi Error: GeSHi could not find the language actionscript3 (using path /nfs/c03/h01/mnt/85630/domains/nightdrops.com/html/wp-content/plugins/snipplr/geshi/geshi/) (code 2)
Of course, the stage in FlashExample will not be null, since the DocumentClass is always added to the display list.
With this trick, you always have the stage at hand, by simply referencing FlashExample.staticStage anywhere on your code.
Do you want to leave a comment?