13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Working with motion twe<strong>en</strong>s<br />

Motion object names<br />

Flash Player 9 and later, Adobe AIR 1.0 and later, requires Flash CS3 or later<br />

In the previous case, Flash automatically g<strong>en</strong>erated the name __motion_Symbol1_2 for the Motion object. It attached<br />

the prefix __motion_ to the display object name. Thus, the automatically g<strong>en</strong>erated name is based on the instance<br />

name of the target object of the motion twe<strong>en</strong> in Flash. The duration property of the Motion object indicates the total<br />

number of frames in the motion twe<strong>en</strong>:<br />

__motion_Symbol1_2.duration = 200;<br />

By default, Flash automatically names the display object instance whose motion twe<strong>en</strong> is copied, if it does not already<br />

have an instance name.<br />

Wh<strong>en</strong> you reuse ActionScript created by Flash in your own animation, you can keep the name that Flash automatically<br />

g<strong>en</strong>erates for the twe<strong>en</strong> or you can substitute a differ<strong>en</strong>t name. If you change the twe<strong>en</strong> name, make sure that you<br />

change it throughout the script.<br />

Alternately, in Flash you can assign a name of your choosing to the target object of the motion twe<strong>en</strong>. Th<strong>en</strong> create the<br />

motion twe<strong>en</strong> and copy the script. Whichever naming approach you use, make sure that each Motion object in your<br />

ActionScript code has a unique name.<br />

Describing the animation<br />

Flash Player 9 and later, Adobe AIR 1.0 and later, requires Flash CS3 or later<br />

The addPropertyArray() method of the MotionBase class adds an array of values to describe every twe<strong>en</strong>ed<br />

property.<br />

Pot<strong>en</strong>tially the array contains one array item for every keyframe in the motion twe<strong>en</strong>. Oft<strong>en</strong> some of these arrays<br />

contain fewer items than the total number of keyframes in the motion twe<strong>en</strong>. This situation occurs wh<strong>en</strong> the last value<br />

in the array does not change for the remaining frames.<br />

If the l<strong>en</strong>gth of the array argum<strong>en</strong>t is greater than the duration property of the Motion object, addPropertyArray()<br />

adjusts the value of the duration property accordingly. It does not add keyframes for the properties that were<br />

previously added. The newly added keyframes persist for the extra frames of the animation.<br />

The x and y properties of the Motion object describe the changing position of the twe<strong>en</strong>ed object as the animation is<br />

running. These coordinates are the values that are most likely to change in every keyframe, if the position of the display<br />

object changes. You can add additional motion properties with the addPropertyArray() method. For example, add<br />

the scaleX and scaleY values if the twe<strong>en</strong>ed object is resized. Add the scewX and skewY values if it is skewed. Add the<br />

rotationConcat property if it rotates.<br />

Use the addPropertyArray() method to define the following twe<strong>en</strong> properties:<br />

x horizontal position of the transformation point of the object in the coordinate space of its par<strong>en</strong>t<br />

y vertical position of the transformation point of the object in the coordinate space of its par<strong>en</strong>t<br />

z depth (z-axis) position of the transformation point of the object in the coordinate space of its par<strong>en</strong>t<br />

scaleX horizontal scale as a perc<strong>en</strong>tage of the object as applied from the transformation point<br />

scaleY vertical scale as a perc<strong>en</strong>tage of the object as applied from the transformation point<br />

Last updated 6/6/2012<br />

338

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!