A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Using Flex Builder - setting stage width/height

  1. #1
    Junior Member
    Join Date
    Jun 2007

    Using Flex Builder - setting stage width/height

    Hi there,

    I have recently started using Flex Builder for my Actionscrtipt 3 projects because it is has a much better text editor and is designed around the eclipse framework. However I am having trouble with what should be a simply task.

    Flex builder compiles a swf for me from my main application file which is just an .as file. I therefore cannot put a variable reference on my main timeline and pass it through to any of my classes(cannnot do this on main timeline):
    var _stage:Stage = this;
    I can acess the stage in one of my classes in order to add a child but cannot set the width and height and Flex seems to automatically compile my swf at 550 * 400.
    		public function PropShop(){
    			nav = new Navigation();
    			stage.scaleMode = "noScale"; //does work
    			stage.align = "B";//does work
    			stage.stageWidth = 990; //not working
    			stage.stageHeight = 720; //not working
    			stage.addChild(nav);//does work
    This is the constructor for my main application class where I would like to initially set the stage width and height. I'm pretty sure you cannot dynamically change the stage dimensions once the swf has been compiled but I don't know how to go about changing them beforehand.

    Hope you can help,


    Last edited by gaffafoote; 03-17-2008 at 11:25 AM.

  2. #2
    You can do it using the SWF meta tag. It must be directly before your main class definition.


    [SWF(width="800", height="600", backgroundColor="#ffffff", frameRate="30")]


  3. #3
    Junior Member
    Join Date
    Jun 2007
    Thanks for this. Unfortunately I think this metatag might only work in a Flex project. I'm am running a Actionscript project in Flex Builder. Flex builder 3 is compiling a swf from my main-application file which is a .as file. Thus if i put your meta tag infront of the main class definition it errors.

    Does this make sense or am I entirely wrong?

  4. #4
    Junior Member
    Join Date
    Jun 2007
    Apologies, this has worked. I was being a plank. Thanks.

  5. #5
    Senior Member rachil0's Avatar
    Join Date
    Jul 2007
    Columbus, OH.
    Also, mxmlc has command line parameters for setting many of the stage attributes (size, background color, framerate).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width

HTML5 Development Center