Skip to main content
Version: 9.0.2

sb.animationCreate

sb.animationCreate(fps, [autoDestroy], [endCallback])

Create a new animation at the desired frame rate (fps). The second parameter (optional), auto_destroy, tells if the animation should be released once completed. If you specify a value of 1 the animation will be released and the returned id is not valid once the animation has completed. The third parameter (optional) indicates a callback function to be invoked when the animation is complete.

Parameters

ParameterTypeDescription
fpsnumberThe animation frame rate.
autoDestroynumberPass 1 in to release the animation once completed.
endCallbackfunctionProvide a JavaScript function to be called at the end of the animation.

Returns

TypeDescription
stringAn animation id to be used on future animation calls, null on failure.

Example

function animationCreate(fps) {
var id = sb.animationCreate(fps);
}

//Example of creating an animation with an animation complete callback
var animationState = "STOPPED";
function animationCreate1(fps) {
var id = sb.animationVreate(fps, 0, animationComplete);
sb.animationTrigger(id, {context="my_layer.my_control", id="my_control_animation"});
animationState = "RUNNING";
}

//The callback's first argument will be the completed animation's id.
//When triggered with an animation instance id (e.g., "my_control_animation"),
//otherwise it will be the id returned from calling animation_create.
function animation_complete(id) {
animationState = "COMPLETED"
}