如何使as3 AnimatorFactory播放多个帧?

时间:2011-12-11 09:57:32

标签: flash actionscript-3

我正在尝试在时间轴中设置动画,然后“将动画复制为3”,以便我可以重复使用动画。问题是当我把AS放到一个类中时,它只想运行1帧,而不是继续动画。我可以使用一些帮助来弄清楚为什么这只运行一帧而不是完整的17帧。

编辑:所以我想出了如何做到这一点。对于其他任何无法做到的人,我都在发布如何使其成功。

package 
{
import fl.motion.AnimatorFactory;
import fl.motion.MotionBase;
import fl.motion.Motion;
import flash.filters.*;
import flash.geom.Point;

public class CustomClass extends MovieClip
{
            // I moved vars here 
    private var __motion_tocInside_328:MotionBase;
    private var __animFactory_tocInside_328:AnimatorFactory;

    public function CornerNavBtn()
    {
        // constructor code
        clickArea.addEventListener(MouseEvent.CLICK, activateChosen);   
    }

    public function animateOutLargeCorner():void
    {
                    // I remove the if statement so I can rerun the animation.
        __motion_tocInside_328 = new Motion();
        __motion_tocInside_328.duration = 17;

        // Call overrideTargetTransform to prevent the scale, skew,
        // or rotation values from being made relative to the target
        // object's original transform.
        // __motion_tocInside_328.overrideTargetTransform();

        // The following calls to addPropertyArray assign data values
        // for each tweened property. There is one value in the Array
        // for every frame in the tween, or fewer if the last value
        // remains the same for the rest of the frames.
        __motion_tocInside_328.addPropertyArray("x", [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);
        __motion_tocInside_328.addPropertyArray("y", [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);
        __motion_tocInside_328.addPropertyArray("scaleX", [1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000]);
        __motion_tocInside_328.addPropertyArray("scaleY", [1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000]);
        __motion_tocInside_328.addPropertyArray("skewX", [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);
        __motion_tocInside_328.addPropertyArray("skewY", [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);
        __motion_tocInside_328.addPropertyArray("rotationConcat", [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);
        __motion_tocInside_328.addPropertyArray("blendMode", ["normal"]);
        __motion_tocInside_328.addPropertyArray("cacheAsBitmap", [false]);
        __motion_tocInside_328.addPropertyArray("alphaMultiplier", [1.000000,0.878937,0.765625,0.660187,0.562562,0.472687,0.390625,0.316438,0.250000,0.191437,0.140625,0.097687,0.062500,0.035188,0.015625,0.003937,0.000000]);

        // This call to initFilters supplies the Motion with an Array;
        // of the fully-qualified class names of the filters in the
        // target's DisplayObject.filters list, in the same order and
        // indices.
        __motion_tocInside_328.initFilters(["flash.filters.GlowFilter"], [0], -1, -1);

        // The following calls to addFilterPropertyArray assign data;
        // values for each tweened filter's properties.
        __motion_tocInside_328.addFilterPropertyArray(0, "blurX", [6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6], -1, -1);
        __motion_tocInside_328.addFilterPropertyArray(0, "blurY", [6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6], -1, -1);
        __motion_tocInside_328.addFilterPropertyArray(0, "strength", [0.00,1.58,1.38,1.19,1.01,0.85,0.70,0.57,0.45,0.34,0.25,0.18,0.11,0.06,0.03,0.01,0.00], -1, -1);
        __motion_tocInside_328.addFilterPropertyArray(0, "knockout", [false], -1, -1);
        __motion_tocInside_328.addFilterPropertyArray(0, "inner", [false], -1, -1);
        __motion_tocInside_328.addFilterPropertyArray(0, "quality", [BitmapFilterQuality.MEDIUM], -1, -1);
        __motion_tocInside_328.addFilterPropertyArray(0, "alpha", [1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00], -1, -1);
        __motion_tocInside_328.addFilterPropertyArray(0, "color", [0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff], -1, -1);

        // Create an AnimatorFactory instance, which will manage;
        // targets for its corresponding Motion.
                    // this is where I changed it, I put the var declaration up top but kept the assigning here.
        __animFactory_tocInside_328 = new AnimatorFactory(__motion_tocInside_328);
        __animFactory_tocInside_328.transformationPoint = new Point(0.500000,0.500000);

        // Call the addTarget function on the AnimatorFactory
        // instance to target a DisplayObject with this Motion.
        // The second parameter is the number of times the animation
        // will play - the default value of 0 means it will loop.

        __animFactory_tocInside_328.addTarget(<instance name>, 1);
    }

}

}

2 个答案:

答案 0 :(得分:0)

将您的最后一行更改为:

    __animFactory_tocInside_328.addTarget(cornerLarge, 0);

现在重复一遍。您的值为“1”,这意味着它只会播放一次。第二个参数默认为“0”循环。

Check out the documentation on this method

答案 1 :(得分:0)

所以我明白了。我在上面编辑了我的帖子,我也在这里回答它,以便未来的人可以在遇到同样的问题时找到它。

package 
{
import fl.motion.AnimatorFactory;
import fl.motion.MotionBase;
import fl.motion.Motion;
import flash.filters.*;
import flash.geom.Point;

public class CustomClass extends MovieClip
{
        // I moved vars here 
private var __motion_tocInside_328:MotionBase;
private var __animFactory_tocInside_328:AnimatorFactory;

public function CornerNavBtn()
{
    // constructor code
    clickArea.addEventListener(MouseEvent.CLICK, activateChosen);   
}

public function animateOutLargeCorner():void
{
                // I remove the if statement so I can rerun the animation.
    __motion_tocInside_328 = new Motion();
    __motion_tocInside_328.duration = 17;

    // Call overrideTargetTransform to prevent the scale, skew,
    // or rotation values from being made relative to the target
    // object's original transform.
    // __motion_tocInside_328.overrideTargetTransform();

    // The following calls to addPropertyArray assign data values
    // for each tweened property. There is one value in the Array
    // for every frame in the tween, or fewer if the last value
    // remains the same for the rest of the frames.
    __motion_tocInside_328.addPropertyArray("x", [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);
    __motion_tocInside_328.addPropertyArray("y", [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);
    __motion_tocInside_328.addPropertyArray("scaleX", [1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000]);
    __motion_tocInside_328.addPropertyArray("scaleY", [1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000]);
    __motion_tocInside_328.addPropertyArray("skewX", [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);
    __motion_tocInside_328.addPropertyArray("skewY", [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);
    __motion_tocInside_328.addPropertyArray("rotationConcat", [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);
    __motion_tocInside_328.addPropertyArray("blendMode", ["normal"]);
    __motion_tocInside_328.addPropertyArray("cacheAsBitmap", [false]);
    __motion_tocInside_328.addPropertyArray("alphaMultiplier", [1.000000,0.878937,0.765625,0.660187,0.562562,0.472687,0.390625,0.316438,0.250000,0.191437,0.140625,0.097687,0.062500,0.035188,0.015625,0.003937,0.000000]);

    // This call to initFilters supplies the Motion with an Array;
    // of the fully-qualified class names of the filters in the
    // target's DisplayObject.filters list, in the same order and
    // indices.
    __motion_tocInside_328.initFilters(["flash.filters.GlowFilter"], [0], -1, -1);

    // The following calls to addFilterPropertyArray assign data;
    // values for each tweened filter's properties.
    __motion_tocInside_328.addFilterPropertyArray(0, "blurX", [6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6], -1, -1);
    __motion_tocInside_328.addFilterPropertyArray(0, "blurY", [6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6], -1, -1);
    __motion_tocInside_328.addFilterPropertyArray(0, "strength", [0.00,1.58,1.38,1.19,1.01,0.85,0.70,0.57,0.45,0.34,0.25,0.18,0.11,0.06,0.03,0.01,0.00], -1, -1);
    __motion_tocInside_328.addFilterPropertyArray(0, "knockout", [false], -1, -1);
    __motion_tocInside_328.addFilterPropertyArray(0, "inner", [false], -1, -1);
    __motion_tocInside_328.addFilterPropertyArray(0, "quality", [BitmapFilterQuality.MEDIUM], -1, -1);
    __motion_tocInside_328.addFilterPropertyArray(0, "alpha", [1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00], -1, -1);
    __motion_tocInside_328.addFilterPropertyArray(0, "color", [0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff], -1, -1);

    // Create an AnimatorFactory instance, which will manage;
    // targets for its corresponding Motion.
                // this is where I changed it, I put the var declaration up top but kept the assigning here.
    __animFactory_tocInside_328 = new AnimatorFactory(__motion_tocInside_328);
    __animFactory_tocInside_328.transformationPoint = new Point(0.500000,0.500000);

    // Call the addTarget function on the AnimatorFactory
    // instance to target a DisplayObject with this Motion.
    // The second parameter is the number of times the animation
    // will play - the default value of 0 means it will loop.

    __animFactory_tocInside_328.addTarget(<instance name>, 1);
}

}

}