Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

actionscript flex, how to send browser width to the swf itself

I'm working with flex, but actionscript ideas are just as good.

The flex <s:Application> tag has height="100%" width="100%" so the swf fits the browser as the browser gets resized.

My problem is that I have a <s:Label> that I need to position based on the real/current size of the browser.

<s:Application height="100%" width="100%">
     .....
     <s:Label text="hello" x="?" y=">" />

</s:Application>

I heard it's possible to use Application.application.width; but I get a compile error, that it doesn't know what that is.

Any ideas how to do this. I'm trying to get the current size of the swf in the browser, as the browser resizes.

like image 381
touB Avatar asked Mar 18 '10 17:03

touB


1 Answers

As far as I can tell the following should work. Application.application simply is the same as this provided you are in the base application. The binding should allow the size to change after initialization.

<s:Application height="100%" width="100%">
     .....
     <s:Label text="hello" x="{width}" y="" />

</s:Application>

Edit : I just checked and it does work. To put your Label in the middle of the stage you simply have to put it like that

<s:Application height="100%" width="100%">
         .....
         <s:Label text="hello" x="{width/2}" y="{height/2}" />

</s:Application>
like image 62
Axelle Ziegler Avatar answered Oct 06 '22 02:10

Axelle Ziegler