Tech Per

01 Dec

Resizing Flex Dialog to Flash Dimensions

Not long ago, we had created a flex dialog with fixed width and height, which gave users with less screen resolution a real problem. The dialog was opening with the titlebar and close buttons outside the screen. Hence, the dialog couldn’t be closed and it couldn’t be moved.

Here is how to make the dialog resize itself according to the screen estate that the flash has been given:


<?xml version="1.0" ?>
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="onCreationComplete()">
    <mx:Script><![CDATA[
        import mx.core.Application;
        private function onCreationComplete() : void {
            height = Application.application.stage.height - 20;
            width = Application.application.stage.width - 20;
        }
]]></mx:Script>
</mx:Panel>

It is really simple. You go through the Application singleton to reach the Stage. And the stage know about the width and height of the flash.

2 Responses to “Resizing Flex Dialog to Flash Dimensions”

  1. 1
    Movember at calm in the chaos Says:

    [...] Tech Per » Blog Archive » Resizing Flex Dialog to Flash Dimensions [...]

  2. 2
    polesen Says:

    Just a quick note:

    I found it better to simply use “Application.application.height”, instead of going through the “stage” instance.

    I had a problem with incorrectly reported height from the “stage.height” property when in a popped up, modal Panel instance. Strange.

Leave a Reply

© 2009 Tech Per | Entries (RSS) and Comments (RSS)

GPS Reviews and news from GPS Gazettewordpress logo