How to get the same effect as TweenLite.to in as3

209 Views Asked by At

I'am using this code:

TweenLite.to(auto, 4, {x:666.15, y:375.6});

from greensock but I got some issues with it. It woun't go back to his originally x and y coordinates in combination with hittestobject. so does someone have an code or an solution to get the same effect as TweenLite.to??

1

There are 1 best solutions below

0
Szczups On

If you're using TweenLite to tween some object that has hitTest checked on each frame you can use updateTo() or reverse() on Tween. This would look something like this:

var tw:TweenLite = TweenLite.to( auto, 4, { x: 555, y: 375, onUpdate: checkHitTest } );
function checkHitTest(){
   //check here for possible hit and call updateTo method
   tw.updateTo({ x: 20, y: 30 }, false );
   //last parameter defines if tween should be modified or if new tween should be created
}