Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 649409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:56:27+00:00 2026-05-13T21:56:27+00:00

I am new to ActionScript so excuse me if this is a stupid question.

  • 0

I am new to ActionScript so excuse me if this is a stupid question.

So, I created a class, extended the sprite class, and now in the constructor I am trying to set the Sprite’s width and height properties which are inherited from the DisplayObject. However, after I set this.width and this.height, and print the values, I get 0 for both.

What the heck is going on? When I view the livedocs I see that DisplayObject has width and height listed as public properties. I have been able to instantiate a Sprite directly, and set the width and height after it’s been instantiated, so I don’t get it.

package  {
    import flash.display.*;

    public class ScrollBar extends Sprite {
        public function ScrollBar(width:Number, height:Number) {
            trace(width + "x" + height);
            this.width = width;
            this.height = height;
            trace(this.width + "x" + this.height);          
    }
}

Output:

20x400
0x0
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:56:28+00:00Added an answer on May 13, 2026 at 9:56 pm

    From the docs:

    The width is calculated based on the
    bounds of the content of the display
    object. When you set the width
    property, the scaleX property is
    adjusted accordingly … Except for
    TextField and Video objects, a display
    object with no content (such as an
    empty sprite) has a width of 0, even
    if you try to set width to a different
    value.

    You’ll need to render something as part of the sprite to get a valid w/h.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am very new to ActionScript and Flash development so excuse any incorrect terminology
Using Flex Builder : I have created a new Actionscript Project. I want to
I'm completely new to Actionscript and I'm trying to figure out if it's possible
I'm new to actionscript. I'm trying to make a menusystem that will jump to
I'm new to Actionscript (v3), 20 years C++ though, and I'm just trying to
I'm fairly new to actionscript 2 and HTTP, but I need to be able
I'm new to actionscript and I have noticed that many variable names in actionscript
I'm new to ActionScript 3 (without any experience with Flash development) and I was
Before all: excuse my english :) Ok, here we go - im developing mostly

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.