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")]
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
License
This work is published under a CC-GNU LGPL.
[…] – 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); […]
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
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 =)
Yeah. Just found this one too… I appreciate the tip. Probably saved me a bit of time searching documentation.