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.

December 1, 2008  Tags: ,   Posted in: Programming, Rich Internet Applications

2 Responses

  1. Movember at calm in the chaos - December 2, 2008

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

  2. polesen - December 2, 2008

    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