Hi there!
I’ve simple sprite added to the root. Everything’s fine untill I’m adding two lines: width=10 and height=10
After that, the sprite becomming invisible. What’s happening and what I’m doing wrong?
var s:Sprite = new Sprite();
s.width = 10;
s.height = 10;
s.graphics.beginFill(0xff0000);
s.graphics.drawCircle(10, 10, 10);
s.graphics.endFill();
addChild(s);
Setting width and height on DisplayObject’s (with the exception of TextField's) causes rendering issues. Refer to scaleX and scaleY for proper sprite scaling.
Apart from that, width and height variables are handled internally based on the maximum width and height of a Sprite’s collection of children. For example, two children side by side causes the maximum width of the parent sprite to match that of the right-most child. Same goes for height.
In the case of BitmapData, you can however set width and height at construction, and alter and manipulate pixels before then attaching the instance to a Bitmap instance.