Difference between stage.width and stage.stageWidth

倖福魔咒の 提交于 2019-12-21 07:13:21

问题


In actionscript 3 (as3) What is the difference between calling stage.width and stage.stageWidth

This was something I remember I got confused about in the past (Adobe's api docs are an artform in obfuscation :) ). Thought I should post it on stackoverflow.


回答1:


stageWidth is basically width of the player window. You probably need this number if you want to know size of your scene. stage.width is calculated as any other width in actionscript. This means, it is width of bounding box around child objects of the stage. For example stage.width of empty.stage is 0. Or if you have only one small square 10 px wide on scene lets say 200px wide, stageWidth is 200, but stage.width is 10




回答2:


I found this article http://ajarproductions.com/blog/2009/03/18/flash-stage-width-vs-stagewidth-in-actionscript-3/ which says:

"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."



来源:https://stackoverflow.com/questions/7422019/difference-between-stage-width-and-stage-stagewidth

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!