user198311
user198311

Reputation: 155

How to get the width and height in ActionScript for a Flex application running inside the flash player in the web browser

Does anyone know how to get the width and height in ActionScript for a Flex application running inside the flash player in the web browser.

e.g. In the web browser I can use the tag to embed a Flex application (as a .swf). To the embed tag, I can provide the dimensions. I would like to get these dimensions inside the flex application action script.

Thanks in advance,

Regards

Vivek

Upvotes: 2

Views: 7778

Answers (3)

nephiw
nephiw

Reputation: 2046

As of Flex 4.0, Adobe recommends using FlexGlobals.topLevelApplication instead of Application.application.

Depending upon what you are doing, you can look into using stage. But, if you do, be aware that the stage will grow to contain movie clips that go outside of the bounds of the application. So the stage is frequently larger than the actual application.

Upvotes: 4

sharvey
sharvey

Reputation: 8185

You can use stage.stageWidth/stage.stageHeight. Be sur to call that from a DisplayObject that is on the display list or else stage is going to be null. It works for both Flex and Actionscript projects.

Upvotes: 0

Markus Johnsson
Markus Johnsson

Reputation: 4019

I Flex you can access Application.application.height and Application.application.width.

Upvotes: 2

Related Questions