# Stopping and starting with a button?

**URL:** https://forum.kirupa.com/t/stopping-and-starting-with-a-button/34752
**Category:** Uncategorized
**Created:** [November 6, 2003, 12:47am UTC](https://forum.kirupa.com/t/stopping-and-starting-with-a-button/34752 "2003-11-06T00:47:25Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![brintonwhite](https://avatars.discourse-cdn.com/v4/letter/b/cdc98d/32.png) [@brintonwhite](https://forum.kirupa.com/u/brintonwhite)
#### Post date: [November 6, 2003, 12:47am UTC](https://forum.kirupa.com/t/stopping-and-starting-with-a-button/34752/1 "2003-11-06T00:47:25Z")

</div>

I have a simple tween that runs over 50 frames, there is no stop action so it loops, just what I want.

I have placed an invisible button over the tweened animation, now here’s my question:

Whe i click on the invisible button the animation stops and when I click on it again, it restarts

So that’s it really, can this be done? I know how to stop the animation by putting a stop in the action script, so I am looking for some actionscript that works on an alternative click method if I am making myself clear? Example:

First click stops it, second click starts it, third click stops it fourth click starts it - this goes on forever.

Thank you.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 6, 2003, 1:50pm UTC](https://forum.kirupa.com/t/stopping-and-starting-with-a-button/34752/2 "2003-11-06T13:50:50Z")

</div>

The easiest way i can think of is:

[AS]  
decision = 0  
on (release) {  
if (decision == 0) {  
\_root.stop();  
decision = 1  
}  
if (decision == 1) {  
\_root.play();  
decision = 0  
}  
}  
[/AS]

very sloppy but it should work (never tested) 🙂

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 6, 2003, 3:10pm UTC](https://forum.kirupa.com/t/stopping-and-starting-with-a-button/34752/3 "2003-11-06T15:10:34Z")

</div>

Thanks for that. I’ll try it.
