Daniel
Daniel

Reputation:

Set window size for standalone application

I want to set the default window size for a flex application that runs with a standalone player. I set width and height to 100% to be able to get the ResizeEvent and being able to adjust the layout if the user changes the window size. But I'd like to also define a default size.

Upvotes: 1

Views: 4301

Answers (3)

sharvey
sharvey

Reputation: 8145

There's two ways to set the default size of a swf:

1) add a compiler argument:

-default-size=800,600

2) use metadata in your flex main mxml or class

mxml:

<mx:Metadata>
     [SWF(width='800', height='600')]
</mx:Metadata>

class:

[SWF(width='800', height='600')]
public class Main extends Application {}

This will tell the compiler what values to put in the header tag of the swf.

Upvotes: 3

Daniel
Daniel

Reputation: 102

I solved it this way: setting the application to a fixed size on startup, and adjusting it when the stage (here: the window) is resized

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
            width="900" height="600"
            applicationComplete="appComplete();">

<mx:Script>
    <![CDATA[

        private function appComplete():void {
            stage.addEventListener(Event.RESIZE, onStageResize);
        }

        private function onStageResize(e:Event):void
        {
            this.width  = this.stage.stageWidth;
            this.height = this.stage.stageHeight;
            validateNow();
        }

Upvotes: 1

Sean Clark Hess
Sean Clark Hess

Reputation: 16059

I'm not sure you can. You can do it with air though. Why would you want a standalone flex app that isn't air? The setting is the air xml file

Upvotes: 0

Related Questions