Careful with this one. It’s easy to miss if you’re accustomed to Actionscript 1 or 2.
stage.width will return the width of the content on the stage and ignore any empty pixels around the edges. So if you only have a 100 px wide rectangle on stage, your stage.width will be 100.
stage.stageWidth will give you the size of the stage, more like Stage.width in Actionscript 2. Use stage.stageWidth if you’re trying to position elements relative to the stage.
Same goes for stage.height and stage.stageHeight.
This entry was posted on Tuesday, December 28th, 2010 at 10:00 am and is filed under ActionScript, Flash, Tutorials. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
You might also like
| Sample BitmapData and Images In AS3, you must give objects in the library class association in order to instantiate them with AS. If you don't... | FullScreen in AS3 Notes: This tutorial covers HTML changes as well. Flash requires an HTML to be in opened in your browser and load... | Flash Optimization – Activate & Deactivate Events Flash optimization is becoming increasing important & with alternative development tools that developers... | Render Event in AS3 ActionScript has long since relied on the enterFrame (onEnterFrame) event for time-based actions, especially animation... |








