[AS3/AS2 only] This plugin allows you to define a callback method that should be called whenever the tween's "ratio" property changes which effectively means that the tweening values changed. This is typically only useful in conjunction with SteppedEase. Also note that the callback should accept one parameter which will refer to the tween itself. This is different than most other callback types, like onComplete and onUpdate which don't pass parameters by default unless you use their onCompleteParams and onUpdateParams counterparts. The reason onChangeRatio works this unique way is to minimize file size (adding an onChangeRatioParams would require either another plugin or adding kb to the main TweenLite class or changing the syntax altogether to onChangeRatio:{func:myFunction, params:[1,2]} which is even more inconsistent) and because it is such a niche plugin (typically only used with SteppedEase which is quite niche itself). It can be very useful to reuse a single callback method but it must be able to figure out which tween changed its ratio and access its target which is why onChangeRatio passes the tween as the parameter.


import com.greensock.TweenLite; 
import com.greensock.plugins.TweenPlugin; 
import com.greensock.plugins.OnChangeRatioPlugin; 
TweenPlugin.activate([OnChangeRatioPlugin]); //activation is permanent in the SWF, so this line only needs to be run once.
TweenLite.to(mc, 3, {x:500, onChangeRatio:changeHandler, ease:SteppedEase.create(5)}); 
function changeHandler(tween:TweenLite):void {
        trace("ratio: " + tween.ratio);


Version: 1.20.3 updated 2017-10-02




        By using GreenSock code, you agree to the terms of use.

        For an all-access pass to premium content

        Join Club GreenSock