Copy link to clipboard
Copied
Hi
I have a script (Thank u Stagprime) that works great when placed directly on the button.
When added into advanced action its not working?
Is this a bug or do I need to tweek the script?
var frameStart;
function playProject() {
if (cpInfoCurrentFrame < 40) {
// If the frame number is lower than 40, play the project as normal
cpCmndGotoFrameAndResume = cpInfoCurrentFrame;
} else {
// If the frame number is 25 or higher, play the project backwards and stop at frame 40
setTimeout(function() {
if (cpInfoCurrentFrame > 40) {
cpCmndGotoFrame = cpInfoCurrentFrame - 1;
playProject();
}
}, 30);
}
}
// Capture the starting frame
var frameStart = cpInfoCurrentFrame;
// Call the function to play the project based on the frame number
playProject();
Copy link to clipboard
Copied
This is very similar to the advanced action which I had in mind, although I would have preferred to have two parameters instead of the literals 25 and 40.
Do you have other commands in the advanced action?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
@Stagprime Thanks for the explanation, I think the OP didn't understand fully how to apply your script. As usual I try to do it with a shared or advanced action, using a While loop. Problem is the slight time gap between each repetition in a While loop. I don't know why they didn't fix it.
That was the reason for my reaction, I did see that you stored the first frame of the slide.
Copy link to clipboard
Copied
What I meant is, that I fear that the OP used the script he got from you full in one advanced action, and didn't apply the part needed for the On Enter event in the correct place.
Copy link to clipboard
Copied
I got it working just fine thanks to stagprime.
Problem is that the webbrowser dont like to play videos backward so still working on other solutions.