4
$\begingroup$

This simple example gives a strange error.

DynamicModule[{Go = True}, 
  Animate[
    EventHandler[
      Graphics[Rotate[Rectangle[], t]], 
      {"MouseClicked" :> (Go = False)}], 
    {t, 0, 8}, 
    DefaultDuration -> 30, 
    AnimationRunning -> Dynamic[Go]]]

A message window pops up which says:

An unrecognized option name ("AnimationRunning") was encountered while reading a AnimatorBox.

And my message handler doesn't work (it's supposed to stop the animation when I click it). If I replace Dynamic[Go] with simple Go, there are no messages and the animation works correctly (but the message handler is disconnected, of course). So the option per se is perfectly recognized, and the problem is with Dynamic.

What am I doing wrong?

$\endgroup$
  • $\begingroup$ works fine in version 11.3 (Windows 10 - 64 bit). $\endgroup$ – kglr Apr 22 at 20:55
  • $\begingroup$ I've got version 9 for XP Win32. Can't upgrade. $\endgroup$ – user6130990 Apr 22 at 21:03
  • $\begingroup$ Guess I need a workaround. $\endgroup$ – user6130990 Apr 22 at 21:04
  • 1
    $\begingroup$ AnimatorBox didn't have an AnimationRunning option in v9. Animate (the box generator function) does. Using Dynamic as a rhs is supported until v10, IIRC. $\endgroup$ – ihojnicki Apr 23 at 0:36
  • $\begingroup$ You mean "is not supported until v10"? Or I don't get you. $\endgroup$ – user6130990 Apr 23 at 1:30
3
$\begingroup$

A work-around:

Manipulate[EventHandler[Graphics[Rotate[Rectangle[], t]], 
    {"MouseClicked" :> (Go = Not[Go])}],
  {{t, 0}, 0, 8, Animator[##, DefaultDuration -> 30, AnimationRunning -> Go] &}, 
  {{Go, True}, None}, 
  AppearanceElements -> {}]

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ So this was basically a scoping problem with weird symptoms. The ghost control part turned out to be the main one. Thanks! $\endgroup$ – user6130990 Apr 25 at 20:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.