1

当您单击 ageImg 按钮(swf 中的粉红色图像)时,它会调用下一个函数,该函数应该隐藏所有其他图像并将年龄歧视词移到舞台上,但由于某种原因,它在一秒钟后变为空白,并且ageFlash 函数再次启动,导致整个动画从头开始。我不知道它为什么会循环。

[链接到 SWF 文件]

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();
4

1 回答 1

1

You need to kill off the delayed call to the racFlash method you set up in the ageFlash method otherwise your code will continue on its merry way. You can use the TweenLite.killDelayedCallsTo method to do this (see 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');
} 
于 2014-10-17T18:07:28.897 回答