Recently I was trying to make something where one could vary the parameters and press play to see how the animation changed. However, when I tried running the code it would just start automatically. Even if I pressed pause nothing would happen. I managed to narrow the problem down and have made a simple example to illustrate the issue.
If I run the following code I get what I want. (i.e. press play and it starts. Press pause and it stops)
Clear[step,MyAnimation,dynamicVar]
step=0;
dynamicVar={1,2};
MyAnimation[nothing_,something_]:=Module[{},step++;something+{step,step}]
Manipulate[
dynamicVar=MyAnimation[time,{1,2}];
Dynamic@dynamicVar,
{{time,1,""},1,\[Infinity],1,ControlType->Trigger,AnimationRate->2}
]
However, if I replace dynamicVar=MyAnimation[time,{1,2}];
with dynamicVar=MyAnimation[time,dynamicVar];
what I get is something which runs automatically and which one cannot not stop. (I know they give two different results, but the issue lies in the fact that I cannot stop it)
Clear[step,MyAnimation,dynamicVar]
step=0;
dynamicVar={1,2};
MyAnimation[nothing_,something_]:=Module[{},step++;something+{step,step}]
Manipulate[
dynamicVar=MyAnimation[time,dynamicVar];
Dynamic@dynamicVar,
{{time,1,""},1,\[Infinity],1,ControlType->Trigger,AnimationRate->2}
]
Any advice on how to fix this problem?
dynamicVar = MyAnimation[time, dynamicVar]
-- what are you really trying to do? $\endgroup$MyAnimation[time, dynamicVar]
to evaluate and assign the result todynamicVar
. $\endgroup$