Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...

psygnus

Members
  • Posts

    4
  • Joined

  • Last visited

Community Answers

  1. psygnus's post in How to use TweenMax.updateTo to change toVars on the fly was marked as the answer   
    Eureka!
     
    I had to kill the existing tween before creating the new one in order to get a smooth transition.
    Of course, that required keeping a reference of the object in order to have something to kill!
     
    The following code, based on your help and using my object oriented approach gives the best results!
    function MyObj(params) { this.obj = somedata; //construct canvas object this.tween = null; //declare tween and set to null on object creation //..rest of object constructor... }; MyObj.prototype.startTween = function(y, speed) { //"speed" is pixels per second this.tween = TweenLite.to(this.obj, Math.abs(y - this.obj.y) / speed, {y:y, ease:Linear.easeNone, onComplete:on_stop, onCompleteParams:[this.rNum]}); }; MyObj.prototype.stopTween = function() { this.tween.kill(); //Calculate new dest based on some other data newdest = some_calculations; startTween(newdest, speed); }; //create an object a = new MyObj(few_params); //start object tween like this a.startTween(1000, 200); //stop object tween on whatever event type you need simply calling stopTween() a.stopTween(); I am curious to find out what causes that tween jump, if you don't kill the first tween.
    My guess is that the re-calculations to change the tween on the fly are expensive enough to break the smooth motion(?)
     
    Anyway, thanks to your insight i got it. Thanks a million!
×