TransWikia.com

AnimationRunning option of Animate misbehaving

Mathematica Asked by user6130990 on April 22, 2021

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?

One Answer

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

Correct answer by kglr on April 22, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP