Message Boards Message Boards

Why does Animate not wait for user input data?


I would like to input a variable using a form and then use that variable in an animation. A simple example is shown in the code below.

form = FormFunction["length" -> "Number", # &];
datin = form[];
len = datin[["length"]] // N;
\[Theta][t_] = Sin[2 \[Pi] t];

Animate[Graphics[{Disk[{0, 0}, .15], 
   Disk[{l Sin[.2 \[Theta][t]], -l Cos[.2 \[Theta][t]]}, .15] /. 
    l -> len, 
   Line[{{0, 0}, {l Sin[.2 \[Theta][t]], -l Cos[.2 \[Theta][t]]}}] /. 
    l -> len}, PlotRange -> {{-5, 5}, {-9, 1}}], {t, 0, 10, .01}, 
 AnimationRate -> 1, AnimationRunning -> False]

But it seems that the animated graphic attempts to run as soon as the notebook is executed and results in an error message and the graphic painted pink until the data is entered. Is there some way to keep this error from occurring?

POSTED BY: Mike Luntz
10 months ago

Hmm, it waits for input for me (V11.2, MacOS), then displays a non-running animation after input, and finally runs after I click the play button.

POSTED BY: Michael Rogers
10 months ago

Group Abstract Group Abstract