AS3 Pitfalls – Dude, where’s my _xscale?

PROBLEM:

MovieClip._xscale (or MovieClip.xscale) does not light up as a recognized property in AS3. It’s not even listed as a property of the MovieClip class in the documentation. What gives?

SOLUTION:

_xscale and _yscale properties have been replaced by scaleX and scaleY, which are both properties of the DisplayObject class. MovieClip (eventually) extends DisplayObject and inherits these properties.

The second snag is that scaleX and scaleY percentages are now divided by 100. Whereas before, MovieClip._xscale = 100 displayed the clip at its native width, MovieClip.scaleX = 1.0 is the new hotness.

1
MovieClip._xscale = 100; // Displays an object at its full width in Actionscript 2
1
MovieClip.scaleX = 1.0; // Displays an object at its full width in Actionscript 3

Take care when porting AS2 files to AS3.

One thought on “AS3 Pitfalls – Dude, where’s my _xscale?

  1. James

    You’d think xscale would make sense with AS3’s far more logical naming conventions… but anyway thanks for the tip, glad it didn’t take me all day trying to find it!

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *