描述动画

Flash Player 9 及更高版本,Adobe AIR 1.0 及更高版本,需要 Flash CS3 或更高版本

MotionBase 类的 addPropertyArray() 方法添加用于描述每个补间属性的值数组。

该数组可能包含用于补间动画中每个关键帧的数组项。通常,这些数组中的一些数组包含的项数少于补间动画中的关键帧总数。当数组中的最后一个值对于剩下的帧没有更改时,会发生这种情况。

如果数组参数的长度大于 Motion 对象的 duration 属性,则 addPropertyArray() 会相应地调整 duration 属性的值。它不会为以前添加的属性添加关键帧。会为动画的额外帧保持新添加的关键帧。

Motion 对象的 x y 属性描述补间对象在动画运行时不断改变的位置。如果显示对象的位置发生更改,则这些坐标是在每个关键帧中最可能发生更改的值。您可以使用 addPropertyArray() 方法添加其他动画属性。例如,如果调整补间对象的大小,可以添加 scaleX scaleY 值。如果倾斜补间对象,则添加 s cewX skewY 值。如果旋转补间对象,则添加 rotationConcat 属性。

使用 addPropertyArray() 方法可定义以下补间属性:

x

对象的变形点在其父级的坐标空间中的水平位置

y

对象的变形点在其父级的坐标空间中的垂直位置

z

对象的变形点在其父级的坐标空间中的深度(z 轴)位置

scaleX

从变形点开始应用的对象的水平缩放比例(百分比)

scaleY

从变形点开始应用的对象的垂直缩放比例(百分比)

skewX

从变形点开始应用的对象的水平倾斜角度(以度为单位)

skewY

从变形点开始应用的对象的垂直倾斜角度(以度为单位)

rotationX

对象相对于其原始方向围绕 x 轴的旋转

rotationY

对象相对于其原始方向围绕 y 轴的旋转

rotationConcat

动画中的对象的旋转(z 轴)值,相对于前一个方向且从变形点开始应用

useRotationConcat

如果设置此属性,则会在 addPropertyArray() 提供动画数据时导致目标对象旋转

blendMode

BlendMode 类值,指定对象的颜色与底层图形的混合

matrix3D

matrix3D 属性(如果对于关键帧存在此属性);用于 3D 补间;如果使用,则会忽略以前所有的变形属性

rotationZ

对象相对于 3D 父容器从其原始方向开始的 z 轴旋转(以度为单位);用于 3D 补间(而不是 rotationConcat)

在自动生成的脚本中添加的属性取决于在 Flash 中分配给补间动画的属性。在自定义自己的脚本版本时,您可以添加、删除或修改其中一些属性。

下面的代码向名为 __motion_Wheel 的补间动画的属性赋值。在此示例中,补间显示对象在补间动画中的全部 29 个帧中都不更改位置,而是在当前位置上旋转。分配给 rotationConcat 数组的多个值对旋转进行了定义。此补间动画的其他属性值无变化。

__motion_Wheel = new Motion(); 
__motion_Wheel.duration = 29; 
__motion_Wheel.addPropertyArray("x", [0]); 
__motion_Wheel.addPropertyArray("y", [0]); 
__motion_Wheel.addPropertyArray("scaleX", [1.00]); 
__motion_Wheel.addPropertyArray("scaleY", [1.00]); 
__motion_Wheel.addPropertyArray("skewX", [0]); 
__motion_Wheel.addPropertyArray("skewY", [0]); 
__motion_Wheel.addPropertyArray("rotationConcat", 
    [ 
        0,-13.2143,-26.4285,-39.6428,-52.8571,-66.0714,-79.2857,-92.4999,-105.714, 
        -118.929,-132.143,-145.357,-158.571,-171.786,-185,-198.214,-211.429,-224.643, 
        -237.857,-251.071,-264.286,-277.5,-290.714,-303.929,-317.143,-330.357, 
        -343.571,-356.786,-370 
    ] 
); 
__motion_Wheel.addPropertyArray("blendMode", ["normal"]); 

在下一个示例中,名为 Leaf_1 的显示对象会在舞台上移动。该对象的 x y 属性数组为动画的 100 个帧中的每个帧包含不同的值。此外,该对象在舞台上移动时同时在其 z 轴上旋转。 rotationZ 属性数组中的多个项确定了旋转方式。

__motion_Leaf_1 = new MotionBase(); 
__motion_Leaf_1.duration = 100; 
__motion_Symbol1_4.addPropertyArray("y", 
    [     
        0,5.91999,11.84,17.76,23.68,29.6,35.52,41.44,47.36,53.28,59.2,65.12,71.04, 
        76.96,82.88,88.8,94.72,100.64,106.56,112.48,118.4,124.32,130.24,136.16,142.08, 
        148,150.455,152.909,155.364,157.818,160.273,162.727,165.182,167.636,170.091, 
        172.545,175,177.455,179.909,182.364,184.818,187.273,189.727,192.182,194.636, 
        197.091,199.545,202,207.433,212.865,218.298,223.73,229.163,234.596,240.028, 
        245.461,250.893,256.326,261.759,267.191,272.624,278.057,283.489, 
        288.922,294.354,299.787,305.22,310.652,316.085,321.517,326.95,330.475,334, 
        337.525,341.05,344.575,348.1,351.625,355.15,358.675,362.2,365.725,369.25, 
        372.775,376.3,379.825,383.35,386.875,390.4,393.925,397.45,400.975,404.5, 
        407.5,410.5,413.5,416.5,419.5,422.5,425.5 
    ] 
); 
__motion_Symbol1_4.addPropertyArray("scaleX", [1.00]); 
__motion_Symbol1_4.addPropertyArray("scaleY", [1.00]); 
__motion_Symbol1_4.addPropertyArray("skewX", [0]); 
__motion_Symbol1_4.addPropertyArray("skewY", [0]); 
__motion_Symbol1_4.addPropertyArray("z", 
    [ 
        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 
        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 
        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 
    ] 
); 
__motion_Symbol1_4.addPropertyArray("rotationX", [64.0361]); 
__motion_Symbol1_4.addPropertyArray("rotationY", [41.9578]); 
__motion_Symbol1_4.addPropertyArray("rotationZ", 
    [ 
        -18.0336,-17.5536,-17.0736,-16.5936,-16.1136,-15.6336,-15.1536,-14.6736, 
        -14.1936,-13.7136,-13.2336,-12.7536,-12.2736,-11.7936,-11.3136,-10.8336, 
        -10.3536,-9.8736,-9.3936,-8.9136,-8.4336,-7.9536,-7.4736,-6.9936,-6.5136, 
        -6.0336,-7.21542,-8.39723,-9.57905,-10.7609,-11.9427,-13.1245,-14.3063, 
        -15.4881,-16.67,-17.8518,-19.0336,-20.2154,-21.3972,-22.5791,-23.7609, 
        -24.9427,-26.1245,-27.3063,-28.4881,-29.67,-30.8518,-32.0336,-31.0771, 
        -30.1206,-29.164,-28.2075,-27.251,-26.2945,-25.338,-24.3814,-23.4249, 
        -22.4684,-21.5119,-20.5553,-19.5988,-18.6423,-17.6858,-16.7293,-15.7727 
        -14.8162,-13.8597,-12.9032,-11.9466,-10.9901,-10.0336,-10.9427,-11.8518, 
        -12.7609,-13.67,-14.5791,-15.4881,-16.3972,-17.3063,-18.2154,-19.1245, 
        -20.0336,-20.9427,-21.8518,-22.7609,-23.67,-24.5791,-25.4881,-26.3972, 
        -27.3063,-28.2154,-29.1245,-30.0336,-28.3193,-26.605,-24.8907,-23.1765, 
        -21.4622,-19.7479,-18.0336 
    ] 
); 
__motion_Symbol1_4.addPropertyArray("blendMode", ["normal"]);