./Actionscript

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 ()
{
}
}
}[/actionscript]

Download: AS3MetaDimensionTest.as

Discussion

5 comments for “AS3 stage trickery”

  1. […] – snip – i.e the Embed meta data has now to be moved outside the class, the same way as stage meta data exists outside the class (example posted by Mike Jones At FlashGen.com); […]

    Posted by BitTubeBlog » Blog Archive » Correcting ActionScript 3 Example Errors | July 7, 2006, 11:00
  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

    Posted by Markavian | April 24, 2007, 21:48
  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 =)

    Posted by Alex | November 24, 2007, 22:50
  4. Yeah. Just found this one too… I appreciate the tip. Probably saved me a bit of time searching documentation.

    Posted by Marcus | January 25, 2008, 23:58
  5. Thanks for the tip.

    Posted by José Castro | June 6, 2008, 17:31

Post a comment