Actionscript 3 在AS3中使用tween类将对象移动到多个位置?

Actionscript 3 在AS3中使用tween类将对象移动到多个位置?,actionscript-3,tween,Actionscript 3,Tween,嗨,我正在尝试制作一个对象,在本例中为“ship_mc”,移动到屏幕上的3个不同点,但我想使用tween类。我不知道为什么它不工作,任何帮助将不胜感激。 我的代码如下所示 import fl.transitions.Tween; import fl.transitions.easing.*; import fl.transitions.TweenEvent; var myTween01:Tween = new Tween(this, "x", Regular.easeIn, 1416,

嗨,我正在尝试制作一个对象,在本例中为“ship_mc”,移动到屏幕上的3个不同点,但我想使用tween类。我不知道为什么它不工作,任何帮助将不胜感激。 我的代码如下所示

    import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;

var myTween01:Tween = new Tween(this, "x", Regular.easeIn, 1416, 973, 4, true);
var myTween02:Tween = new Tween(this, "y", Regular.easeIn, 206, 446, 4, true);
var myTween03;
var myTween04;
var myTween05;
var myTween06;


myTween01.addEventListener(TweenEvent.MOTION_FINISH, onFinish);
function onFinish(e:TweenEvent):void {
myTween03:Tween = new Tween(this, "x", None.easeIn, 973, 695, 4, true);
myTween04:Tween = new Tween(this, "y", None.easeIn, 446, 222, 4, true);

}

myTween04.addEventListener(TweenEvent.MOTION_FINISH, onFinish1);
function onFinish1(e:TweenEvent):void {
myTween05:Tween = new Tween(this, "x", None.easeIn, 695, 374, 4, true);
myTween06:Tween = new Tween(this, "y", None.easeIn, 222, 239, 4, true);
}
这就是我得到的错误

Symbol 'ship_mc', Layer 'Actions', Frame 1, Line 15 1067: Implicit coercion of a value of type fl.transitions:Tween to an unrelated type Class.
Symbol 'ship_mc', Layer 'Actions', Frame 1, Line 15 1188: Illegal assignment to class Tween.
Symbol 'ship_mc', Layer 'Actions', Frame 1, Line 16 1067: Implicit coercion of a value of type fl.transitions:Tween to an unrelated type Class.
Symbol 'ship_mc', Layer 'Actions', Frame 1, Line 16 1188: Illegal assignment to class Tween.
Symbol 'ship_mc', Layer 'Actions', Frame 1, Line 22 1067: Implicit coercion of a value of type fl.transitions:Tween to an unrelated type Class.
Symbol 'ship_mc', Layer 'Actions', Frame 1, Line 22 1188: Illegal assignment to class Tween.
Symbol 'ship_mc', Layer 'Actions', Frame 1, Line 23 1067: Implicit coercion of a value of type fl.transitions:Tween to an unrelated type Class.
Symbol 'ship_mc', Layer 'Actions', Frame 1, Line 23 1188: Illegal assignment to class Tween.

谢谢,我知道人们会建议使用tweenlite,但我想知道这里有什么问题,否则我就学不到了

您收到的错误消息告诉您发生问题的线路:15、16、22和23:

15: myTween03:Tween = new Tween(this, "x", None.easeIn, 973, 695, 4, true);
16: myTween04:Tween = new Tween(this, "y", None.easeIn, 446, 222, 4, true);

22: myTween05:Tween = new Tween(this, "x", None.easeIn, 695, 374, 4, true);
23: myTween06:Tween = new Tween(this, "y", None.easeIn, 222, 239, 4, true);
前两个tween的代码运行良好,那么前两个tween与其余tween之间的唯一区别是什么?你申报的方式。您需要将
myTween03
myTween04
myTween05
myTween06
声明为tween,以防止抛出错误,因为它认为您正在尝试将默认类初始化为tween,否则。更改:

var myTween03;
var myTween04;
var myTween05;
var myTween06;

并以与第一个和第二个吐温相同的方式初始化它们:

myTween03 = new Tween(this, "x", None.easeIn, 973, 695, 4, true);
myTween04 = new Tween(this, "y", None.easeIn, 446, 222, 4, true);

这基本上说明了变量将在以后的代码中初始化为tweens,并将防止抛出这些错误。

谢谢,这使前两个tweens成为动画,但我得到了以下错误类型error:error#1009:无法访问空对象引用的属性或方法。在Navigationequipment_fla::ship_mc_3/frame1()中,某些内容引用不正确,您是否也更改了
myTween05
myTween06
的代码?我的函数中没有我的eventlistener,因此它不知道引用了什么,噢!非常感谢!没问题=)(如果你认为答案对你有帮助,你应该投票或者接受它作为正确答案)。
myTween03 = new Tween(this, "x", None.easeIn, 973, 695, 4, true);
myTween04 = new Tween(this, "y", None.easeIn, 446, 222, 4, true);