# On and off

**URL:** <https://forum.kirupa.com/t/on-and-off/7913>\
**Category:** Uncategorized\
**Created:** [November 10, 2002, 6:46am UTC](https://forum.kirupa.com/t/on-and-off/7913 "2002-11-10T06:46:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![berdwin](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@berdwin](https://forum.kirupa.com/u/berdwin)\
**Post date:** [November 10, 2002, 6:46am UTC](https://forum.kirupa.com/t/on-and-off/7913/1 "2002-11-10T06:46:21Z")

</div>

I was wondering… out of pure curiosity…  
how do you make a button so that when clicked, it makes a movie clip dissapear, though, when clicked again, makes the clip reappear? perhaps some code? yes? ok thanks :beam:

berdwin

---

<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 10, 2002, 7:17am UTC](https://forum.kirupa.com/t/on-and-off/7913/2 "2002-11-10T07:17:19Z")

</div>

Create a movie clip. Give it the instance name “ball” (as I did in this example, but it can be whatever, just be sure to change it in the code).

Apply this code to the button that makes it disappear

```auto
on (release) {
	_root.ball._visible = false;
}

```

Apply this code to the button that makes it reappear

```auto
on (release) {
	_root.ball._visible = true;
}

```

That is all there is to that.

---

<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 10, 2002, 6:38pm UTC](https://forum.kirupa.com/t/on-and-off/7913/3 "2002-11-10T18:38:23Z")

</div>

I know how to do it with two buttons, but I was wondering about a one button only method… like to toggle something on and off.

I’ve seen it work with the beetle sample files that come with MX where you can toggle rotation and mouse following etc… though I don’t quite understand it. :-\

berdwin

---

<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 10, 2002, 6:56pm UTC](https://forum.kirupa.com/t/on-and-off/7913/4 "2002-11-10T18:56:20Z")

</div>

Nevermind! I’m a genius and figured it out myself, huzzah!! :evil: :beam:  
this is how it goes:

```auto

on (release) {
	myMovie._visible = !myMovie._visible;
}

```

=)

berdwin

---

<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 10, 2002, 7:27pm UTC](https://forum.kirupa.com/t/on-and-off/7913/5 "2002-11-10T19:27:00Z")

</div>

Oh ok! I misread 🙂

Well congrats on solving your problem 🙂
