Flex: Customizing SWF Properties
Monday, November 27th, 2006 by LuisThere are two ways of changing the basic properties of your application in Flex, one is by passing multiple arguments to the command-line compiler and the second one by adding metadata in your Main class.
Yesterday I almost got crazy trying to figure out why one of my projects didn't work when changing the properties of the output swf adding metadata in my Main class, and the answer was very simple, basically the metadata statement has to be placed after any import statement. By placing the metadata statement before the imports, the application properties were set to the default parameters (500 x 375, 24 , blue background).
This doesn't seem to work:
- package
- {
- [SWF(width="200", height="200", frameRate="31", backgroundColor="#FFFFFF")]
- import flash.display.Sprite;
- public class Main extends Sprite
- {
- public function Main()
- {
- trace('stage width: '+stage.stageWidth);
- trace('stage height: '+stage.stageHeight);
- trace('framerate: '+stage.frameRate);
- }
- }
- }
This works:
- package
- {
- import flash.display.Sprite;
- [SWF(width="200", height="200", frameRate="31", backgroundColor="#FFFFFF")]
- public class Main extends Sprite
- {
- public function Main()
- {
- trace('stage width: '+stage.stageWidth);
- trace('stage height: '+stage.stageHeight);
- trace('framerate: '+stage.frameRate);
- }
- }
- }




