Which script can I use to control the loop settings of an animation ?

M.E shared this question 2 years ago
Answered

Which script can I use to control the loop settings of an animation ? - by loop settings I mean the properties that determine whether the animation should be repeated only once or continuously.

Best Answer
photo

There exist nothing to update properties/slider/repeate

In the attachment a possibility with a bolean (loop) and scripts and 1 slider (once).

But I think your idea with the 2 slider is less complicated and more robust.

Comments (7)

photo
1

I don't think that there's a scripting command for this.

Maybe using Repeat command, and setting the suitable conditions, could help.

But it's quite impossible to be more precise if you don't post a sample file and the description of what you want to achieve.

photo
1

Ok.

I have made some randomly generated exercises in GG. And when the student click on a check button, a random animation is shown according to the correctness of the answer.

I use the same slider to control the different animations. And I prefer to do so to make the script as less complicated as possible.

I want most of the animations to be played only once. And others I would like to be played continuously.

Of course I could make a slider for each; one for those who are going to be repeated and one for those who only are going to be shown once.

But I would really prefer just to change the repeat/loop settings of the slider I already use.

I'll try the repeat command and will get back with an update...

photo
1

I tried to use the repeat command, and I can't get GG to repeat the animation.

First I tried to implement it in the same button as either as:

Repeat[ 20, StartAnimation[ Slidername, True ]

or

Repeat[ 20, SetValue[ Slidername, 1 ], StartAnimation[ Slidername, True ] ]

The last script didn't work at all, and the first script didn't get the animation to run more than one time.

Then I tried to split it up in two buttons. So the repeat command was going to execute a script of a button where the slider value first were set to 1 and Subsequently the animation would start. But once again, the animation would only run one time.

For me it seems that the repeat command is executing the script immediately and thereby doesn't wait for executing one more time before the process of the executed script is ended.

So I would very much appreciate a suggestion for how to get the animation be repeated with a script...

photo
photo
2

There exist nothing to update properties/slider/repeate

In the attachment a possibility with a bolean (loop) and scripts and 1 slider (once).

But I think your idea with the 2 slider is less complicated and more robust.

photo
1

Thank you VERY much ! :)

May I ask: Why set the value of the slider to -99999 and not just to -5 or something else... ?

photo
1

Both is possible ("and not something else?": yes: for example -infinity), but when min in the slider is change, then the script must not change because the slider can't go less than -5. Maybe better (and more clear) define min and max as separate variables and use this variable in the slider and also in the script.

photo
1

Ok, so it's only necessary when the minimum value of the slider is changing.

photo
© 2021 International GeoGebra Institute