If I have a custom class subclassing Sprite and it draws some simple objects, how does this work with respect to the Sprite.width & Sprite.height properties? It seems I can draw (for example) a rectangle of any size, bigger than the Sprite size.
Similarly if I set the width/height properties, what happens to the content already drawn?
As a use-case, I might have a stick-man which is drawn as a set of lines, I want to set the man’s height and the rendering is scaled to this.
Are there any issues with width/height being auto-calculated or am I misunderstanding what these properties actually mean?
widthandheightmake much more sense as getters. They take the internal content of the clip, multiply it by scaleX/scaleY and return it.Internally the clip’s scaling is stored as a matrix, and you can access individual elements of the matrix with the
scaleX/scaleYproperties (as well asx,y, androtation).You can also set
widthandheightand there’s some slightly awkward code that runs behind the scenes to make it work. Basically, whatever width you set is immediately turned into ascaleXvalue. For example if you have a 100×100 movieclip, and callwidth = 200, Flash will translate that toscaleX = 2.If then, in the course of its animation, the movieclip grows to 120×100, then it will appear on the stage with a width of 240.
In other words the width and height that you set are applied as scaling factors. It has nothing to do with clipping the content.
For maximum predictability, always set to the
scaleX/scaleYvalues.