DynamicPropsPlugin

[AS3/AS2 only] If you'd like to tween something to a destination value that may change at any time, DynamicPropsPlugin allows you to simply associate a function with a property so that every time the tween is rendered, it calls that function to get the new destination value for the associated property. For example, if you want a MovieClip to tween to wherever the mouse happens to be, you could do:

TweenLite.to(mc, 3, {dynamicProps:{x:getMouseX, y:getMouseY}}); 
function getMouseX():Number {
        return this.mouseX;
}
function getMouseY():Number {
    return this.mouseY;
}

Of course you can get as complex as you want inside your custom function, as long as it returns the destination value, TweenLite/Max will take care of adjusting things on the fly.

You can optionally pass any number of parameters to functions using the "params" special property like so:

TweenLite.to(mc, 3, {dynamicProps:{x:myFunction, y:myFunction, params:{x:[mc2, "x"], y:[mc2, "y"]}}});
function myFunction(object:MovieClip, propName:String):Number {
        return object[propName];
}

Usage

import com.greensock.TweenLite; 
import com.greensock.plugins.*; 
TweenPlugin.activate([DynamicPropsPlugin]); //activation is permanent in the SWF, so this line only needs to be run once.
TweenLite.to(my_mc, 3, {dynamicProps:{x:getMouseX, y:getMouseY}});
    
function getMouseX():Number {
    return this.mouseX;
}
function getMouseY():Number {
        return this.mouseY;
} 

DynamicPropsPlugin is a membership benefit of Club GreenSock ("Shockingly Green" and corporate levels) so it isn't in the public downloads. If you're not a member yet, you can sign up here. Once you join you'll get access to several plugins like this which can be downloaded from your GreenSock account.

Get GSAP

Version: 1.20.4 updated 2018-02-15

Core

    Extras

      Plugins

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

        For an all-access pass to premium content

        Join Club GreenSock