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