A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: AS3 Stage.width not working??

  1. #1
    Junior Member
    Join Date
    May 2007
    Posts
    2

    AS3 Stage.width not working??

    I'm just getting started with AS3 - sorry for the stupid question. All I need to do is access the stage dimensions. I can't use Stage.width or Stage.stageWidth without getting this compile error: 1119: Access of possibly undefined property width through a reference with static type Class.

  2. #2
    half as fun, double the price senocular's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, CA (USA)
    Posts
    4,358
    Stage.width in AS2 was a static property off of the Stage class. In AS3 they are now class properties for the stage instance. The stage instance is accessible from the stage property of DisplayObject instances such as your main timeline.

    code:
    //main timeline:
    trace(stage.stageWidth);


    http://www.kirupa.com/forum/showthre...13#post1952513

  3. #3
    Member
    Join Date
    Dec 2005
    Posts
    70
    Won't work for me either, even if I write

    this.width = stage.stagewidth;

    No matter what I do, won't work

  4. #4
    half as fun, double the price senocular's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, CA (USA)
    Posts
    4,358
    Quote Originally Posted by Sid1120
    Won't work for me either, even if I write

    this.width = stage.stagewidth;

    No matter what I do, won't work
    capital W - stageWidth

  5. #5
    Junior Member
    Join Date
    May 2007
    Posts
    2
    Ok - I was using a capital S in Stage as if it were a class, but if it is lowercase to treat it as an instance it works. Thank you, Senocular!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center