我在AS3中使用Tweenlite和Starling。一切正常,但最后一次重写编译器只是忽略了Tweenlite命令,只是崩溃了这个错误:
[Fault] exception,information = undefined
at com.greensock.core :: Animation()[/ Active / _Flash / _AS3_v12 / src / com / greensock / core / Animation.as:210]
at com.greensock :: TweenLite()[/ Active / _Flash / _AS3_v12 / src / com / greensock / TweenLite.as:445]
at com.greensock :: TweenLite $ / to()[/ Active / _Flash / _AS3_v12 / src / com / greensock / TweenLite.as:919]
这是发生错误的代码:
private function down():void {
TweenLite.to(square, stage.stageHeight / 200, {y: stage.stageHeight - 50, ease: Linear.easeNone});
if (stopped){
TweenLite.to(square, square.y / 200, {y: 50, ease: Linear.easeNone});
stopped = !stopped;
rRight();
} else {
right();
}
}
如果我删除 if 语句青少年发生,如果我离开它,一切都会崩溃。我不明白为什么编译器会跳过补间。
以下是相关的其余代码:
public class Square extends Sprite implements ISquare {
public const square:Quad = new Quad(100, 100);
private var stopped:Boolean;
public function Square() {
}
public function draw():void{
addChild(square);
square.pivotX = square.width / 2;
square.pivotY = square.height / 2;
square.x = 50;
square.y = 50;
stopped = new Boolean(false);
down();
}
...
public function reverseDirection():void{
stopped = !stopped;
TweenLite.killTweensOf(square);
}
private function down():void {
TweenLite.to(square, stage.stageHeight / 200, {y: stage.stageHeight - 50, ease: Linear.easeNone});
if (stopped){
TweenLite.to(square, square.y / 200, {y: 50, ease: Linear.easeNone});
stopped = !stopped;
rRight();
} else {
right();
}
}
private function right():void {
TweenLite.to(square, stage.stageWidth / 200, {x: stage.stageWidth - 50, ease: Linear.easeNone});
if (stopped){
TweenLite.to(square, square.x / 200, {x: 50, ease: Linear.easeNone});
stopped = !stopped;
rUp();
} else {
up();
}
}
...
上下文来源:https://www.dropbox.com/sh/9x2q93o2ff1fsna/AADVJgt5nipDE1pdkgozkOc1a(Square.as)
答案 0 :(得分:2)
因此,Tweenlite内部出现了问题。具体而言,我不知道。
你说当你删除if语句时,一切顺利。
之前,一切都很好。
考虑到你之前的问题,我认为以前一切都不好。这是您的程序第一次实际工作。它是第一次实际补间并完成所有代码的编写。
在查看代码以及我在网上找到的一些反编译代码时,我认为它与此相关:
您不是在等待补间完成。
目前,您在添加之后执行这样的代码:(我已添加注释来解释会发生什么)
private function down():void {
TweenLite.to(square, stage.stageHeight / 200, {y: stage.stageHeight - 50, ease: Linear.easeNone});
//1x tween started
if (stopped){//I dunno where it goes, it goes A here...
TweenLite.to(square, square.y / 200, {y: 50, ease: Linear.easeNone});//2nd tween
stopped = !stopped;
rRight();//and then here
} else {//or it goes B here
right();//and then here
}
}
private function right():void {
TweenLite.to(square, stage.stageWidth / 200, {x: stage.stageWidth - 50, ease: Linear.easeNone});
//B path - 2nd tween started
if (stopped){//idk, but
TweenLite.to(square, square.x / 200, {x: 50, ease: Linear.easeNone});//either 3rd
stopped = !stopped;
rUp();//and on and on
} else {//or
up();//on and on anyway
}
}
private function rRight():void {
TweenLite.to(square, stage.stageWidth / 200, {x: stage.stageWidth - 50, ease: Linear.easeNone});
//A path - 3rd tween started
if (stopped){//idk which way, but
TweenLite.to(square, square.x / 200, {x: 50, ease: Linear.easeNone});//4th
stopped = !stopped;
down();//and on and on
} else {//or
rDown();//still on and on and on
}
}
发生了什么事情,你有一个无限循环,以及Tweenlite BREAKS中的东西。
可能在Tweenlite等待ENTER_FRAME
时,它必须处理您设法添加的所有补间。查看documentation,您似乎可以在onComplete
来电的第三个参数中添加参数TweenLite.to
。你在那里放了一个函数,当补间完成后它会被调用。有关详情,请参阅documentation for onComplete。