1

シンプルなボタンがあり、トランジションを行いたいです。
現在のフレームが1の
場合フレーム2を再生したい現在のフレームが2の
場合フレーム3を再生したい現在のフレームが3の場合フレーム1を再生したい
なぜ私のスクリプトがActionScript3.0で機能しないのですか?ありがとう。

buton1.addEventListener(MouseEvent.CLICK, buton1Click);

function buton1Click(event:MouseEvent):void{
    if(currentFrame == 1){
      gotoAndStop(2); 
    }
    if(currentFrame == 2){
      gotoAndStop(3); 
    }
    if(currentFrame == 3){
      gotoAndStop(1); 
    }
}
4

2 に答える 2

2

ブロックifは常に真です。次のフレームに移動して、そのフレームにいるかどうかをテストします。

ボタンがタイムラインにまたがっている場合、次のようになります。

タイムライン

コードは次のようになります。

stop();

button1.addEventListener(MouseEvent.CLICK, button1Click);

function button1Click(event:MouseEvent):void
{
    switch (currentFrame)
    {
        case 1:
            gotoAndStop(2);
            break;
        case 2:
            gotoAndStop(3);
            break;
        case 3:
            gotoAndStop(1);
            break;
    }
}
于 2012-07-07T21:35:18.453 に答える
1
stop();
stage.addEventListener(MouseEvent.CLICK, button1Click);

function button1Click(event:MouseEvent):void {
    this.gotoAndStop((this.currentFrame % this.totalFrames) + 1);
}

//this way you can change the timeline without changing code
于 2014-10-23T23:43:11.050 に答える