当你点击ageImg按钮(swf中的粉红色图像)时,它会调用下一个应该隐藏所有其他图像的功能,并将年龄歧视字移到舞台上,但出于某种原因,它会在一秒钟后出现空白并且ageFlash函数再次启动,导致整个动画从头开始。我不知道为什么会循环。
import com.greensock.TweenLite;
import com.greensock.TimelineLite;
import com.greensock.plugins.*;
import flash.events.MouseEvent;
var ageismTimeline:TimelineLite = new TimelineLite();
function init():void{
ageFlash();
ageImg.ageism.visible=false;
racImg.racism.visible=false;
hatImg.hate.visible=false;
sexImg.sexism.visible=false;
}
function ageFlash():void{
ageImg.visible=false;
ageImg.buttonMode = true;
ageImg.addEventListener(MouseEvent.CLICK, stopPicLoop);
TweenLite.delayedCall(1,racFlash);
}
function racFlash():void{
racImg.visible=false;
TweenLite.delayedCall(1,hatFlash);
}
function hatFlash():void{
hatImg.visible=false;
TweenLite.delayedCall(1,sexFlash);
}
function sexFlash():void{
TweenLite.delayedCall(1,ageFlash);
ageImg.visible=true;
racImg.visible=true;
hatImg.visible=true;
}
function stopPicLoop(event:MouseEvent):void{
switch (event.type) {
case "click":
trace(event.type);
ageAni();
break;
case 2:
break;
case 3:
break;
}
}
function ageAni():void{
racImg.visible=false;
hatImg.visible=false;
sexImg.visible=false;
ageImg.visible=true;
ageImg.ageism.visible=true;
ageismTimeline.from(ageImg.ageism,.5,{y:stage.stageHeight});
trace('ageism');
}
init();
答案 0 :(得分:1)
您需要终止对racFlash
方法中设置的ageFlash
方法的延迟调用,否则您的代码将继续以愉快的方式继续。您可以使用TweenLite.killDelayedCallsTo
方法执行此操作(请参阅documentation):
function ageAni():void{
racImg.visible=false;
hatImg.visible=false;
sexImg.visible=false;
ageImg.visible=true;
ageImg.ageism.visible=true;
TweenLite.killDelayedCallsTo(racFlash); // kill the delayed call
ageismTimeline.from(ageImg.ageism,.5,{y:stage.stageHeight});
trace('ageism');
}