Be a Supporter!

Checkboxes

  • 307 Views
  • 4 Replies
New Topic Respond to this Topic
OpiumNinja
OpiumNinja
  • Member since: May. 13, 2010
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Checkboxes 2010-05-22 21:10:43 Reply

What is the code to find out if a checkbox is checked or not, im trying to make it so that when a button is pressed, if the checkbox is checked, the sound plays 99999 times, and if it isnt, it plays once


That's so mint.

BBS Signature
Torrunt
Torrunt
  • Member since: May. 3, 2007
  • Offline.
Forum Stats
Member
Level 22
Programmer
Response to Checkboxes 2010-05-25 03:58:46 Reply

Just used an if statment and a boolean.
e.g:

var checked:Boolean = false;

if (buttonpressed){
	if (checked){
		checked = false;
	} else {
		checked = true;
	}
}

then wherever you're starting the sound just make an if statement that checks the boolean.

This is really basic stuff, you should really know this already if you're trying to use actionscript (and if you're not then what the hell are you doing).


BBS Signature
Afro-Ninja
Afro-Ninja
  • Member since: Mar. 2, 2002
  • Offline.
Forum Stats
Moderator
Level 44
Game Developer
Response to Checkboxes 2010-05-25 04:50:54 Reply

are you using the CheckBox component? and if so, AS2 or 3?


BBS Signature
CaptainPoncho
CaptainPoncho
  • Member since: Nov. 29, 2003
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to Checkboxes 2010-05-25 05:22:10 Reply

Need more info. But to toggle a boolean upon clicking you can simply:

boxChecked = !boxChecked;

And then obviously look at that value for whatever you need.


BBS Signature
Torrunt
Torrunt
  • Member since: May. 3, 2007
  • Offline.
Forum Stats
Member
Level 22
Programmer
Response to Checkboxes 2010-05-25 05:31:08 Reply

At 5/25/10 05:22 AM, CaptainPoncho wrote: Need more info. But to toggle a boolean upon clicking you can simply:

boxChecked = !boxChecked;

And then obviously look at that value for whatever you need.

Oh my god, i was looking for something like that. I had no idea it was that simple XD i feel dumb, thanks for sharing that though!


BBS Signature