The use of MovieClips within Flash development has become second nature to most of us. As for modifying its properties, it has also become a part of our everyday Flash routine. It simply does not require any second thoughts when modifying them. It’s time for a little change.
In AS3, modifying a MovieClip’s properties has changed a bit but it’s a change that will unify its syntax for the better.
Getting Started With AS3: MovieClip Properties
Below are the most commonly used MovieClip properties demonstrated in AS2 and AS3. The changes are minimal, however, it’s important that you are able to point out the differences. This will help prevent any annoying ActionScript errors when using AS3 in the future.
Positioning: Determine the position of a MovieClip using its x and y coordinates
//--- AS2 myMc._x = 100; myMc._y = 100; //--- AS3 myMc.x = 100; myMc.y = 100;
Scaling using percentages: Scale a MovieClip based on its existing size
//--- AS2 myMc._xscale = 10; //Note: Value expects a whole number myMc._yscale = 10; //Note: Value expects a whole number //--- AS3 myMc.scaleX = .10; //Note: Value expects a decimal number myMc.scaleY = .10; //Note: Value expects a decimal number
Scaling using height/width: Scale a MovieClip using an exact height/width value
//--- AS2 myMc._height = 50; myMc._width = 100; //--- AS3 myMc.height = 50; myMc.width = 50;
Rotation: Rotating a MovieClip
//--- AS2 myMc._rotation = 90; //--- AS3 myMc.rotation = 90;
Visibility: Control a MovieClip’s visiblity
//--- AS2 myMc._visible = false; //--- AS3 myMc.visible = false;
Transparency: Adjusting the alpha or transparency of a MovieClip
//--- AS2 myMc._alpha = 75; //Note: Value expects a whole number //--- AS3 myMc.alpha = .75; //Note: Value expects a decimal number <h3>Differences
Were you able to point out the biggest differences? If so, you’d notice the days of some properties using underscore while others didn’t are over. The underscore of MovieClip properties has removed for the sake of simplicity. Finally!
Also, take a look at the scaleX, scaleY, and alpha properties – they now expect a numerical decimal value instead of a whole number.
Hopefully, this info has helped you out in what you were looking to accomplish.