Jump to content


Checking button activation


  • You cannot reply to this topic
3 replies to this topic

#1 porgeet

    Young Padawan

  • Members
  • Pip
  • 9 posts
  • Gender:Male

Posted 27 June 2006 - 03:30 PM

Hello there.

I was wondering if anyone could point me in the direction of a good tutorial.

What I'm looking for is a was of checking if a button has been turned on or off. And if it's on perform something different when other buttons are clicked, or rolled over.

I was looking at if statements, but I can't find a relivant tutorial. There is one on checking the active states of buttons. But it seems a little to advanced for me.

Any help would be greatly received.

Thanks.

#2 MAdEinUK1

    Young Padawan

  • Members
  • Pip
  • 74 posts

Posted 28 June 2006 - 12:24 PM

http://www.thecodebehind.com/code/flash/ac...tton-state.aspx

There you go.

#3 porgeet

    Young Padawan

  • Members
  • Pip
  • 9 posts
  • Gender:Male

Posted 30 June 2006 - 02:11 PM

Thanks MadeinUK, but unfortunatly I don't understand that one.

Edit

I was thinking of setting a variable if a button is clicked. Could anyone tell me how to do that ?

Edited by porgeet, 30 June 2006 - 04:19 PM.


#4 Tromac

    Young Padawan

  • Members
  • Pip
  • 56 posts

Posted 10 July 2006 - 04:20 AM

If you create a variable that acts like a switch (eg. If it has a value of 1 it's on, if 0 it's off) you could do it. Give each button it's own variable (button1, button2, etc) and just use an IF statement to check the value of the variable (Eg, if button 1 has a value of 1, then do...)

say your variable is called button1:
button1 = 0
This means the switch is off (Button 1 is depressed)

Then on button1, your script would look something like this:
on (release){
	button1 = 1
}
This means when you press button 1, the value of the variable is changed to 1 (on).

Later on, if you want actions to be different depending on if that button was pressed, use an IF statement simmilar to this:
if(button1 = 1){
	//******INSERT SCRIPT FOR IF BUTTON HAS BEEN PRESSED*******
}else if(button1 = 0){
	//******INSERT SCRIPT FOR IF BUTTON HAS NOT BEEN PRESSED*******
}
I hope this helps :)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users