Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

action script: check properties whether buttonmovieclip on/off 2

Status
Not open for further replies.

kitten

Technical User
May 1, 2001
64
AU
Hi guys! bit of action script troubles:

what i want to happen:
a movie clip react once to a mouse click, but the any click after the first will get no response.in the first frame of the main timeline i declare a variable:

var counter = 0;


on release i check to see if counter = 0
if counter = 0 the code is executed and i add one to the variable counter
counter++;
so that the next time there is a click the if loop is false and nothing happens.

except it dosent work, not even the first click gets a response. so i tried declaring a global variable in another situation, which also didnt work: what i want to happen is on release check if the light is on if its on then turn it off if the light is off then turn it on.

in the first frame of the main timeline i put
_global.lightson = true;

then on the movieclip of the light, which is also on the main timeline i put the code

on (release) {
if(lightson=true){
setProperty(lights,_alpha,0);
_global.lightson=false;
}else if (lightson=false){
setProperty(lights,_alpha,100);
_global.lightson=true;
}

}




if anyone could help me out with the coding i'd really appreciate it!!!


Kitten ^_-
 
When you set a variable, you use 1 "=", but in a if comparison statement you have to use 2 "==", otherwise you're just setting that value to the variable.

if(lightson == true){...

else if (lightson == false){...

 
Try this:

Code:
on(release){
	if (_global.lightson==true){
		_root.lights._alpha = 0;
		_global.lightson = false;
	}
	else {
		_root.lights._alpha = 100;
		_global.lightson = true
	}
}

Keep your _global variable set as is.

Hope it helps

Wow JT that almost looked like you knew what you were doing!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top