开发者

How to modify a already made tween?

开发者 https://www.devze.com 2022-12-29 23:08 出处:网络
I have a tween like this : new Tween(myObject, \"x\",null,nowPosition,finalPosition,time,true); sometween.start();

I have a tween like this :

new Tween(myObject, "x",null,nowPosition,finalPosition,time,true);
sometween.start();

Now when the tween has not finished and is somewhere in the middle and the final position changes. I want this tween to be modified so instead of moving to its already defined postion the object goes to开发者_StackOverflow the final position. Any ideas?


There are many ways to achieve that, but the lazy thing that comes to mind is using the continueTo() method, assuming you're using fl.transition.Tween.

e.g.:

import fl.transitions.Tween;

var nowPosition:Number = 0;
var finalPosition:Number = 200;
var time:int = 3;
var sometween:Tween = new Tween(myObject, "x",null,nowPosition,finalPosition,time,true);
sometween.start();

stage.addEventListener(MouseEvent.MOUSE_DOWN, update);

function update(event:MouseEvent):void {
    sometween.continueTo(mouseX,.2);
}

HTH, George

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号