Forums

Full Version: changing target values of running tweens
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Good morning,

this demo plays around with a modification of the Tween class of the flare library which allows to change and add target values of running tweens.

By clicking on the left node which is traversing over the display in this demo the following changes of the running tween are triggered:
  • The x target value is changed from 300 to 100.
  • The tweening of the lineColor value is stopped. This is achieved through setting the target value to the current value.
  • A new tweening of the fillColor from gray to red is added.
  • The y target value of 300 stays unmodified.
These changes will be triggered after 3/4 of the tween process if no click on the left node occured before. The right node traversing over the display is initially tweened in the same manner (except a different x position).

In order to run this demo you would have to temporary replace the Tween class of the flare lib with the attached modified version of this class.

This demo was stimulated by an explanation by Jeff on this issue in the flare forum

http://sourceforge.net/forum/forum.php?t..._id=757572

Rather than back interpolating as suggested I try to achieve the same result by using the current value as the start value of the new Interpolator and correcting the tween fraction values for the modified target values instead. The lazy guy advantage of this approach seems to be that no back interpolating methods have to implemented for the different Interpolator classes. Nevertheless there is a little calculation overhead drawback. I guess the most reasonable way would be that each Interpolator class extension has its own back interpolating method but for now I shy away from modifying to many flare classes in my projects and in addition can't get my head around how to back interpolate colors.

See the first reply for the new modified Tween class

Feedback of course most welcome.

martin

this demo in action


ps A great tween lib with a lot of inspiring features:

http://blog.greensock.com/tweenliteas3/
Hello,

just quick update on this one. I am pretty convinced now that back interpolating can't really work in all cases since you can't ensure that the back interpolated value is valid in the scope of the variable (e.g. if the current color value of the running tween is white and the updated target value is black). So I guess the solution must be something around correcting the fraction values but this is most likely just another display of my confusion.

I attached a new version of the modified Tween class to this thread which uses the reset() method of the Interpolators instead of creating a new Interpolator when the target value is updated.

cheers

m
Reference URL's