# Action Button to Start and Stop animation

**URL:** https://cl.desmos.com/t/action-button-to-start-and-stop-animation/5742
**Category:** Questions
**Created:** [June 25, 2024, 9:16pm UTC](https://cl.desmos.com/t/action-button-to-start-and-stop-animation/5742 "2024-06-25T21:16:21Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Michael\_Wiernicki](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/michael_wiernicki/32/221_2.png) [@Michael\_Wiernicki](https://cl.desmos.com/u/Michael_Wiernicki)
#### Post date: [June 25, 2024, 9:16pm UTC](https://cl.desmos.com/t/action-button-to-start-and-stop-animation/5742/1 "2024-06-25T21:16:21Z")

</div>

I’m trying to use an action button to start and stop an animation and I’ve gotten it to start the animation, but I can’t seem to get the cl right to stop it. The goal is for students to start the rocket traveling to the space station, then stop it as close to the space station as possible (either before or after). Here is the screen I’m working on: [Rockets to Round](https://teacher.desmos.com/activitybuilder/custom/6679dd709acc29868be68ebf) . Any help you can provide is greatly appreciated.

---

<div class="post-metadata">

### Author: ![Daniel\_Wekselgreene](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_wekselgreene/32/1819_2.png) [@Daniel\_Wekselgreene](https://cl.desmos.com/u/Daniel_Wekselgreene)
#### Post date: [June 25, 2024, 9:56pm UTC](https://cl.desmos.com/t/action-button-to-start-and-stop-animation/5742/2 "2024-06-25T21:56:27Z")

</div>

Does it have to be an action button? Or are you ok using controls within the graph? If so, this example may help.

https://www.desmos.com/calculator/p9rdvmrnjc?embed

If you want it to be an action button, let me know.

---

<div class="post-metadata">

### Author: ![Bryn](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/bryn/32/40_2.png) [@Bryn](https://cl.desmos.com/u/Bryn)
#### Post date: [June 26, 2024, 2:16am UTC](https://cl.desmos.com/t/action-button-to-start-and-stop-animation/5742/3 "2024-06-26T02:16:33Z")

</div>

I don’t know what the OP would prefer, but I have tended to avoid “custom-made” buttons like this in a graph, as they don’t look so good on different sized screens (e.g. phones, small tablets). One advantage with using standard components is that they tend to be designed to adapt to different screen layouts (also probably more likely to have accessibility capabilities).

---

<div class="post-metadata">

### Author: ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)
#### Post date: [June 26, 2024, 3:50pm UTC](https://cl.desmos.com/t/action-button-to-start-and-stop-animation/5742/4 "2024-06-26T15:50:28Z")

</div>

It looks to me that you had an idea, but may have a minor error. You’ve defined `a_0` in the graph CL as a `lastValue`, but the only button capture is “distance”. You may also want to conditionally define the time based on pressCount otherwise the timer (and animation) restarts.

---

<div class="post-metadata">

### Author: ![Michael\_Wiernicki](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/michael_wiernicki/32/221_2.png) [@Michael\_Wiernicki](https://cl.desmos.com/u/Michael_Wiernicki)
#### Post date: [June 27, 2024, 1:32pm UTC](https://cl.desmos.com/t/action-button-to-start-and-stop-animation/5742/5 "2024-06-27T13:32:56Z")

</div>

I was hoping to use an action button/buttons to make this happen. Thanks.

---

<div class="post-metadata">

### Author: ![Daniel\_Wekselgreene](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_wekselgreene/32/1819_2.png) [@Daniel\_Wekselgreene](https://cl.desmos.com/u/Daniel_Wekselgreene)
#### Post date: [June 27, 2024, 3:53pm UTC](https://cl.desmos.com/t/action-button-to-start-and-stop-animation/5742/6 "2024-06-27T15:53:43Z")

</div>

Sure, here’s one approach. Let me know if this works for you or not.

> **[\[Copy of\] Grade 4 Unit 1: Rockets to Round • Activity Builder by Desmos...](https://teacher.desmos.com/activitybuilder/custom/667b9740175b4e38c9b34afa)**
>
> Students will round and compare larger whole numbers using number lines and place value understanding.
> 
> Thanks to Claire Denning for sharing her activity which provided the inspiration for this project.

---

<div class="post-metadata">

### Author: ![Michael\_Wiernicki](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/michael_wiernicki/32/221_2.png) [@Michael\_Wiernicki](https://cl.desmos.com/u/Michael_Wiernicki)
#### Post date: [June 27, 2024, 10:19pm UTC](https://cl.desmos.com/t/action-button-to-start-and-stop-animation/5742/7 "2024-06-27T22:19:47Z")

</div>

I think this will do great and I think I see what I was missing, now. Thank you for all your help!
