greensock / GreenSock-AS3

Public repository for GreenSock's ActionScript 3 libraries like GSAP (TweenLite, TweenMax, etc.) and LoaderMax. For AS2, see the GreenSock-AS2 repository and for JavaScript, see the GreenSock-JS repository. Main site: http://www.greensock.com
409 stars 144 forks source link

TimelineLite bug? #13

Closed feipinxiang closed 7 years ago

feipinxiang commented 7 years ago

Press the keyboard change state. Press 4 then 5, the result is right. Press 7 then 5, the result is wrong. If I use tweenlite to change the obj state, the timelinelite gotoAndStop function will not run correctly. Why is that? How to fix it?

`

package {

import com.greensock.TimelineLite;
import com.greensock.TweenLite;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
public class testTweenLiteTimeLine extends MovieClip 
{
    public var mc1:Sprite;
    public var mc2:Sprite;
    private var timeline:TimelineLite;

    public function testTweenLiteTimeLine() 
    {
        mc1 = new Sprite();
        mc1.graphics.beginFill(0xff0000);
        mc1.graphics.drawRect(0, 0, 50, 50);
        mc1.graphics.endFill();
        addChild(mc1);

        mc2 = new Sprite();
        mc2.graphics.beginFill(0x00ff00);
        mc2.graphics.drawRect(0, 0, 50, 50);
        mc2.graphics.endFill();
        addChild(mc2);
        mc2.x = 60;

        timeline = new TimelineLite();
        timeline.append(TweenLite.to(mc1, 2, {alpha:0}));
        timeline.append(TweenLite.to(mc2, 2, {alpha:1}));
        TweenLite.to(mc2, 0, {alpha:0});
        //timeline.gotoAndStop(timeline.duration());

        stage.addEventListener(KeyboardEvent.KEY_DOWN, onSKD);
    }

    private function onSKD(e:KeyboardEvent):void 
    {
        switch (e.keyCode) 
        {
            case Keyboard.NUMBER_1:
                timeline.play();
            break;
            case Keyboard.NUMBER_2:
                timeline.restart();
            break;
            case Keyboard.NUMBER_3:
                timeline.reverse();
            break;
            case Keyboard.NUMBER_4:
                timeline.gotoAndStop(0);
            break;
            case Keyboard.NUMBER_5:
                timeline.gotoAndStop(timeline.duration());
            break;
            case Keyboard.NUMBER_6:
                timeline.gotoAndPlay(0);
            break;
            case Keyboard.NUMBER_7:
                TweenLite.to(mc2, 0, {alpha:0});
            break;
            default:
        }
        trace(e.keyCode);
    }

}

}

`

jackdoyle commented 7 years ago

We don't really support the ActionScript tools anymore, sorry. But have you tried setting overwrite:false on the tween? I wonder if you're running into an overwriting issue.

feipinxiang commented 7 years ago

Thanks, that solved my problem