sb.animationTrigger(animation_id, data)



Trigger an animation to run. If an animation_id is used to trigger the animation, then it must be the return value from sb.animationCreate(). If a name is used to trigger an animation, then that name must be the name of the animation specified in Designer. This function can take an optional parameter, data. The data parameter is an object that contains the variables for the extra arguments to set.


When an animation is triggered from ANIMATION_NOT_RUNNING, each of the steps duration and offset is resolved. All the steps from the beginning of the animation, until the time specified by progress* duration, are computed, this means their to/from/tween values are resolved and the values are applied as appropriate.

When an animation is triggered from ANIMATION_PAUSED, the animation will either seek forwards or backward, depending on the previous progress and the newly specified progress. When seeking forwards, all the steps that have not yet been processed, up until the specified progress will be computed and the values applied. When seeking backward, the previously computed steps will be directly reversed using the values from when the animation steps were originally computed. When an animation is triggered without pausing, it will reach ANIMATION_NOT_RUNNING, at which point the animation is partially released from memory and the computed steps can no longer be used. This may have an adverse effect on those animations with relative start values.

    animation_id         The animation to trigger
    data                 An object containing the variables for the extra arguments to set. The variables can be
                id              The animation id used in the case of multiple animations with the same name        
                context         The fully qualified name of an object in the model which will be used as the context for the animation
                progress        A value from 0.0-1.0, the percentage into the animation to begin. (default is 0)
                pause           A boolean value to indicate if the animation should be paused immediately after seeking to the value specified by progress, (default is false)
                reverse         A boolean value to indicate that the animation should run in reverse. (default is false)
                cleanup         A boolean value to indicate that the running instance of an animation should be removed from memory upon completion. Specifying false will 
                                enable a complex animation to be triggered in reverse after completion. (default is true)

function createAnimation(context) {    
    var data = {};    
    // slide the x position 400 pixels over 2000 ms and auto-destroy    
    // it on completion    
    id = sb.animationCreate(60, 1);    
    data.rate = "linear";    
    data.duration = 2000;    
    data.offset = 0; = 400;    
    data.key = "mylayer.mycontrol.grd_x";   
    sb.animationAddStep(id, data);    

//Example of using sb.animationTrigger passing animation names.
function cbToggleCur5day() {    
    if(cur5dayToggle == false) {        
    } else {        

//Example of using sb.animationTrigger with context.
function cbToggleCur5day() {    
    var data = {};    
    data.context = "Layer1.mycontrol";    
    sb.animationTrigger("show_5day", data);
Was this article helpful?
0 out of 0 found this helpful