Question

Using Tween class maybe? I tried the easeOut. But if will write 2 Tween, the 2nd one will overwrite the 1st one, so I only see the obj moving in the 2nd Tween direction, not the 1st Tween direction.

I know the coordinates for the 2nd Tween below is not correct (because all coordinates should follow the defined reference point), so I need to find out the logo's width and height. But is alright now because it is for testing purpose.

import fl.transitions.Tween;
import fl.transitions.easing.*;
logo.visible = false;
addChild(logo);

circle.addEventListener(MouseEvent.CLICK, moveObj);

function moveObj(e:MouseEvent):void{
    logo.visible = true;
    var tweenRight:Tween = new Tween(logo,"x",None.easeOut, 100, 300, 2, true);
    var tweenLeft:Tween = new Tween(logo,"x",None.easeOut, 300, 100, 2, true);

}
Was it helpful?

Solution

You are firing the two tweens at the same time so you can for example listen to motion finish event and launch the other tween at this moment:

import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;

logo.visible = false;
addChild(logo);

circle.addEventListener(MouseEvent.CLICK, moveObj);

function moveObj(e:MouseEvent):void{
    logo.visible = true;
    var tweenRight:Tween = new Tween(logo,"x",None.easeOut, 100, 300, 2, true);
    tweenRight.addEventListener(TweenEvent.MOTION_FINISH, onTweenRightFinished);
}
function onTweenRightFinished(e:TweenEvent):void {
    e.currentTarget.removeEventListener(TweenEvent.MOTION_FINISH, onTweenRightFinished);
    var tweenLeft:Tween = new Tween(logo,"x",None.easeOut, 300, 100, 2, true);
}

OTHER TIPS

You have both these happening at the same time, you'll need to delay the second one till after the first ends.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top