AS3 stage trickery

Posted on Thursday 27 October 2005


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:
  1. -default-size 200 100 -default-frame-rate 26 -default-background-color #FFFFFF[actionscript]
  2.  
  3. 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:
  4. [actionscript][SWF(width="200", height="100", backgroundColor="#FFFFFF")]

Below is a quick example of it in use:

ACTIONSCRIPT:
  1. package {
  2.     import flash.display.MovieClip;
  3.     // Set the stage dimensions  and color here
  4.     [SWF(width="600", height="100", backgroundColor="#DFEEEF")]
  5.    
  6.     public class AS3MetaDimensionTest extends MovieClip
  7.     {
  8.         public function AS3MetaDimensionTest ()
  9.         {
  10.         }
  11.     }
  12. }

Download: AS3MetaDimensionTest.as

License

This work is published under a CC-GNU LGPL.



4 Comments for 'AS3 stage trickery'

  1.  
    July 7, 2006 | 11:00 am
     

    […] – 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); […]

  2.  
    April 24, 2007 | 9:48 pm
     

    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.  
    November 24, 2007 | 10:50 pm
     

    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.  
    Marcus
    January 25, 2008 | 11:58 pm
     

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



Leave a comment

(required)

(required)


Information for comment users
Line and paragraph breaks are implemented automatically. Your e-mail address is never displayed. Please consider what you're posting.

Use the buttons below to customise your comment.

Comments are moderated so please only submit once


RSS feed for comments on this post | TrackBack URI