If you wish to reuse the script across multiple buttons - you can substitute variables for the numeric values and pass in different values for each button. See the code below. // place this code as an onEnter action
// declare the variable to hold the starting frame
var frameStart;
// This function will serve to back up a project
// The function will take three parameters
// numFrames will denote the number of frames to back up each execution
// totalFrames will denote the total overall frames to be backed up
// freqTime will be the timeframe that we move back by the numFrames variable
function backUp(numFrames,totalFrames,freqTime) {
setTimeout(function() {
cpCmndGotoFrame = cpInfoCurrentFrame - numFrames;
if (cpInfoCurrentFrame > frameStart - totalFrames) {
backUp(numFrames,totalFrames,freqTime);
}
},freqTime);
} Now you could have three different buttons with minimum code. // Capture the starting frame
var frameStart = cpInfoCurrentFrame;
// call the function
// 1 frame at a time
// a total of 25 frames
// every half second
backUp(1, 25, 500);
----------------------------------------
// Capture the starting frame
var frameStart = cpInfoCurrentFrame;
// call the function
// 1 frame at a time
// a total of 10 frames
// every half second
backUp(1, 10, 500);
----------------------------------------
// Capture the starting frame
var frameStart = cpInfoCurrentFrame;
// call the function
// 1 frame at a time
// a total of 25 frames
// every 50 milliseconds
backUp(1, 25, 50); Adjust the values as needed to achieve the desired effect. Be sure to keep the function itself in the onEnter action so that they can keep a proper scope.
... View more