AS3 stage trickery

So here I am – finally getting time to play with AS3 and I wanted to play about with the stage size of my ‘main’ SWF. Now for those not already upto speed with this or haven’t had time to play with Flex Builder 2 alpha and AS3 here is how it can be set:

Using the mxmlc compiler you can add the following parameters:
[actionscript]-default-size 200 100 -default-frame-rate 26 -default-background-color #FFFFFF[actionscript]

Or is you want to add it into your main SWF, you can do this via the metadata in the actual AS file like so:
[actionscript][SWF(width=”200″, height=”100″, backgroundColor=”#FFFFFF”)][/actionscript]

Below is a quick example of it in use:

[actionscript]package {
import flash.display.MovieClip;
// Set the stage dimensions and color here
[SWF(width=”600″, height=”100″, backgroundColor=”#DFEEEF”)]

public class AS3MetaDimensionTest extends MovieClip
public function AS3MetaDimensionTest ()

Download: AS3MetaDimensionTest.as

Mike Jones


  1. Pingback: BitTubeBlog » Blog Archive » Correcting ActionScript 3 Example Errors
  2. Hi,

    Thanks for posting this meta-data example – I’m trying to use AS3 from text editor and command line up… and was struggling to find out how to set the stage size from the Flex 2 / ActionScript 3.0 documentation. The stageWidth and stageHeight properties don’t explain this limitation very well on Adobe’s pages.

    Kind regards,
    – Markavian

  3. Excellent example! I just got started working with AS3, and this was a bit of a pain in the beginning. I kept trying to modify the html container of the swf, but it kept rewriting it every time I made changes to the AS. Going to have to look into this whole metadata stuff =)

  4. Yeah. Just found this one too… I appreciate the tip. Probably saved me a bit of time searching documentation.

Comments are closed.