Setting framerate and stage size in AS3 project using Flex

March 10th, 2008 by Adrian Parr

UPDATE 29/07/2010: Flash CS4 and CS5 now support this metadata, and will override the stage properties that are set in the IDE.

If you are creating an AS3 only project in Flex then at some point you will want to set the framerate, stage size, and stage colour. This is not obvious to find and can be done in one of two ways.

The first method is by providing this information as compiler arguments in the Flex IDE. Go to Project > Properties > ActionScript Compiler. And in the ‘Additional compiler arguments:’ textfield you could enter the following …

-default-frame-rate 25 -default-background-color #FFFFFF
-default-size 800 600

The second method is by putting this information in to your main AS3 class as metadata. For example …

package {
     import flash.display.Sprite;

     [SWF(width='800',height='600',backgroundColor='#ffffff',frameRate='25')]

     public class Test extends Sprite {
          public function Test() {

          }
     }
}

Make sure you put the SWF Metadata AFTER any import statements.

Here are a couple of other blog entries on the subject …

Posted in ActionScript 3.0, Flex |

2 Responses

  1. John Tuttle Says:

    I think it needs to be frameRate (with a capital ‘R’). Doesn’t seem to work with a lower-case ‘r’.

  2. Adrian Parr Says:

    @John: Thanks for spotting that. I’ve now corrected the sample code.

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.