On and off

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

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

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

Apply this code to the button that makes it reappear

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

That is all there is to that.

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

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


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

=)

berdwin

Oh ok! I misread :slight_smile:

Well congrats on solving your problem :slight_smile: