gre.animationCreateTween(name, tweenCallback)

Create a new animation tweening (interpolation) function that can be used by both JavaScript and Animation Timeline animations. The name of the tweening function cannot collide with any existing animation tweening names. The callback function is a generic tween function that will be provided with specific parameters outlining the desired range of the values being tweend and the frame at which the values should be interpolated.

The tweening function is called with four parameters elapsed, base, change, duration. The elapsed value indicates the interpolation location and is in the range from [0,duration] so if one wanted to derive the percentage that the animation has completed, it would be elapsed/duration. The base value represents the numeric starting point of interpolation and the end point of the animation will be base+change. These four values can be applied to various transforms to return a single floating point value that represents the desired outcome of the interpolation function at that point in time. The output of the interpolation is clamped to the range [base,base+change] though this restriction may be lifted in future releases of Storyboard.

    name              The name to use for the tween operation, it is case-sensitive and must not collide with other tween names
    tweenCallback     The callback function to be invoked when an animation using the named tween function is invoked

    true on successful registration

//Re-implemented linear tween
function customTweenCB(elapsed, base, change, duration) {    
    return base + ((change * elapsed) / duration);

//This is called at application initialization to register the custom
//tween function
function cbRegisterTween(context) {    
    sb.animationCreateTween("MyTween", CustomTweenCB);

//Create an animation that fades out a layer and uses the custom
//tween function
function cbAnimation(context) {    
    var id = sb.animationCreate(60);    
    var data = {};    
    data.rate = "MyTween";    
    data.duration = 2000;    
    data.offset = 0;    
    data.from = 255; = 0;    
    data.key = "MyScreen.MyLayer.grd_alpha";    
    sb.animationAddStep(id, data);    
Was this article helpful?
0 out of 0 found this helpful