I am working on an ActionScript 3.0 module in my day job, and although I am new to ActionScript, I rarely touch the documentation (yeah yeah, I know I should do it more often =) ), most of the time it works, may be because I was on Java before.
Last day, I needed to find out the stage’s height somewhere, so I just typed
and thanks to intelli-sense, it quickly told me that it was
i was looking for. But something strange happened and i was not getting the value i expected. After a couple of hours of hair pulling, it dawned on me that I should be using
instead of
to get stage’s height.
I can’t say whether Adobe/Macromedia’s decision to use
and
instead of
and
was right, but the property name is not abundantly clear in what it is going to return.
Technorati Tags: actionscript 3.0, stage.height, stage.width



December 15th, 2007 at 5:35 pm
very interesting, but I don’t agree with you
Idetrorce
December 15th, 2007 at 7:07 pm
exactly what is it that you don’t agree with?
February 13th, 2008 at 6:55 pm
Hi,
stage.stageHeight returns the height of the actual stage (i.e. the area you see when running your movie), whereas stage.height returns the height of the CONTENT on the stage.
Say, you’ve set the dimensions of the stage to 500×500 and added a movieclip with the dimensions 100×100 anywhere on the stage, you would get the following:
trace(stage.height); // Outputs “100″
trace(stage.stageHeight); // Outputs “500″
If you have several movieclips, buttons, etc. on your stage, stage.height gives you the total height of all content on stage.
Hope this makes sense.
February 13th, 2008 at 10:14 pm
I agree with you till on that stage.height returns *actual* height.
But I don’t agree with the rest, I think (I didn’t dig deeper into it that’s why I only *think* so) that stage.stageHeight returns the height of the *viewable* area (i.e. the height and width at which the movie is being displayed).
I say so because in the module mentioned above, I was trying to make my Sprite scale (and thereby incorporate more content into it) upon resizing the browser window. Using stage.stageHeight and stage.stageWidth worked for rescaling (i.e. calculating the size of viewable area and resizing the sprite accordingly).
I may be wrong, let me know if it is so.