stage.width vs. stage.stageWidth in Actionscript 3

Justin | ActionScript, tips | Wednesday, March 18th, 2009

Careful with this one. It’s easy to miss if you’re accustomed to Actionscript 1 or 2.

Stage Width Example

stage.width will return the width of the content on the stage and ignore any empty pixels around the edges. So if you only have a 100 px wide rectangle on stage, your stage.width will be 100.

stage.stageWidth will give you the size of the stage, more like Stage.width in Actionscript 2. Use stage.stageWidth if you’re trying to position elements relative to the stage.

Same goes for stage.height and stage.stageHeight.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Fark
  • StumbleUpon
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • Reddit
  • Technorati
  • MySpace
  • email
  • Twitter

Related Topics



2 Comments »

  1. Good post. This is stage.wdith vs stage.Stagewidth can def be tricky.

    Comment by Mike — May 28, 2009 @ 2:59 pm

  2. Great job, thank you for sharing.

    Comment by Sharedtut — February 3, 2010 @ 4:22 pm

RSS feed for comments on this post. TrackBack URI

Leave a comment

You may use the following html tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped=""> .

Subscribe without commenting

Powered by WordPress