Need Help with turning a movie clip on/off

I have written this script for a button to turn a movie clip on or off. I want it to set the movie clip’s opacity to 0 if it is already at 100 or to 100 if it is already at 0. But it will only set it to 0 if it is 100. Can anyone tell me why my script doesn’t work? Thank you.

on(release) {
if (this.Highlights._alpha = 100) {
setProperty(“Highlights”, _alpha, “0”);
setProperty(“HighlightsButton”,_alpha, “50”);
} else {
setProperty(“Highlights”, _alpha, “100”);
setProperty(“HighlightsButton”, _alpha, “100”);
}
}

You need to use == to check if something is equal to something else. Also setProperty is replaced by the much easier dot syntax…

[AS]on(release) {
if (Highlights._alpha == 100) {
Highlights._alpha = 0;
HighlightsButton._alpha = 50;
} else {
Highlights._alpha = 100;
HighlightsButton._alpha = 100;
}
}[/AS]

continued…

If you really want to make your clip invisible (_alpha = 0 can be seen on 16bit color), you can use the _visble property…

[AS]on(release) {
//if Highlights _visible property is true
if (Highlights._visible) {
//make set it to false to hide the clip
Highlights._visible = false;
HighlightsButton._alpha = 50;
} else {
//else set it to true to make it reappear
Highlights._visible = true;
HighlightsButton._alpha = 100;
}
}[/AS]

Great, that’s even better. I didn’t know alpha could be seen on 16bit display so alpha was the only way i could think of to turn the clip off. Thank you for the help. It work right now.

I did try the == before but it still didn’t work. Was that because i was using setProperty along with the .syntax on the line above?

*Originally posted by lostinbeta *
_alpha = 0 can be seen on 16bit color
Didnt know dat, thx lostinbeta. :thumb:

It’s good to know that we’re all still learning.

drclare: I believe it wasn’t working when you used == because you also used “this” (this.Highlights).

claudio: no problem :thumb:

Oh, ok. Thanks again.