2011-12-11 36 views
0

我正在尝试在时间轴上进行动画制作,然后“将动作复制为as3”,以便我可以重复使用动画。问题是,当我将AS放入课堂时,它只想运行1帧,并且不会继续播放动画。我可以使用一些帮助,找出为什么这只运行一个帧而不是全部17.如何让as3 AnimatorFactory播放多个帧?

编辑:所以我想通了如何做到这一点。对于无法做到的任何其他人,我正在发布如何让我的工作成果。

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); 
    } 

} 

} 
+0

值得注意的是,动画在独立播放器中工作正常,但在浏览器中打开或按Ctrl + Enter时,它不起作用。 – Ghost9

回答

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); 
} 

} 

} 
0

你的最后一行改成这样:

__animFactory_tocInside_328.addTarget(cornerLarge, 0); 

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

Check out the documentation on this method

+0

无论它是否设置为0,1或17,它仅在一个类中播放一帧。这不是一个解决方案。另外,我不希望它循环播放,我希望它播放一次。 – Ghost9

+0

您可能会发现,您有几个“属性关键帧”已定义,但“cornerLarge”动画片段内只有一个“关键帧”。您可以尝试将“cornerLarge”定义为Sprite,或将17帧添加到“cornerLarge”时间轴。不知道你的时间表的整个结构,这是我可以做的最有帮助的。 –

+0

经过对其他具有类似问题的编码人员进行大量研究并分析您的代码(您只更改了2个属性)后,我强烈建议您使用Greensock,TimelineLite或TimelineMax重新计算代码(http://www.greensock.com/timelinelite /)。你可以做三件或更少的事情,少一点头痛。 –