views:

304

answers:

3

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.

A: 

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

Sean Clark Hess
I'd like a standalone app that isn't air because it does not need installing and can be run right away.
+1  A: 

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();
  }
Daniel
+1  A: 

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.

sharvey