Flash 如何使as3 AnimatorFactory播放多个帧?
我试图在时间轴中设置动画,然后将运动复制为as3,以便可以重用动画。问题是,当我将AS放入类中时,它只想运行1帧,而不继续动画。我需要一些帮助来弄清楚为什么这只运行一帧而不是完整的17帧 编辑:所以我想出了怎么做。对于任何其他人谁不能做到这一点,我张贴如何使我的工作Flash 如何使as3 AnimatorFactory播放多个帧?,flash,actionscript-3,Flash,Actionscript 3,我试图在时间轴中设置动画,然后将运动复制为as3,以便可以重用动画。问题是,当我将AS放入类中时,它只想运行1帧,而不继续动画。我需要一些帮助来弄清楚为什么这只运行一帧而不是完整的17帧 编辑:所以我想出了怎么做。对于任何其他人谁不能做到这一点,我张贴如何使我的工作 package { import fl.motion.AnimatorFactory; import fl.motion.MotionBase; import fl.motion.Motion; import flash.filt
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);
}
}
}
将最后一行更改为:
__animFactory_tocInside_328.addTarget(cornerLarge, 0);
现在它重复了。您的值为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);
}
}
}
值得注意的是,动画在单机播放器中运行良好,但在浏览器或ctrl+enter中打开时不起作用。无论设置为0、1或17,在类中仅播放一帧。这不是一个解决办法。此外,我不希望它循环,我希望它播放一次。您可能会发现,您有几个已定义的属性关键帧,但在cornerLarge movieclip中只有一个关键帧。您可以尝试将cornerLarge定义为精灵,或在cornerLarge时间线上添加17帧。在不了解时间线的整个结构的情况下,这是我能做的最有帮助的。在对其他有类似问题的编码人员进行大量研究之后,并分析您的代码,您只更改了2个属性,我强烈建议您使用greensock、TimeLineSite或TimelineMax对代码进行重新因子化。你可以用三行或更少的话来做你想做的事情,而不会那么头痛。我想我必须这样做。我喜欢使用运动编辑器,这就是为什么我想使用这种方法。现在,我想直接从代码开始制作动画将是唯一的方法。我发现greensock如果用于按成本计费的业务应用程序,则需要许可。因为我不愿意支付年度许可费,所以我必须使用普通的flash Tween来获得我想要的东西。谢谢你的建议。如果有人提出建议,我仍然希望动画师工厂能够正常工作,但我想我会转而使用as3 tween类。