Be a Supporter!

Boolean with Arrays?

  • 221 Views
  • 3 Replies
New Topic Respond to this Topic
Aprime
Aprime
  • Member since: Aug. 15, 2005
  • Offline.
Forum Stats
Member
Level 47
Game Developer
Boolean with Arrays? 2013-04-10 16:43:49 Reply

Hello!

Right... so, I know how to use booleans.. to a certain extent.

Firstly I state my boolean exists by calling it a variable.

var attackIsSelected:Boolean = true;

I like booleans mainly due to the ifStatements available

if (attackIsSelected){
trace("attack");
}

Is it possible to use Booleans that have more than the two options of true and false?
I would believe this would be done through Arrays of somesort, although I'm not to familiar with them -especially not in conjunction with Booleans.

I cannot find tutorials for these to this manner either.

Please could you give a basic script on how I can use arrays with Booleans and I'll apply them accordingly

If there were
-4 options my boolean could have
- if statments like if(thisBoolean=quarter)
that would be perfect

I hope this makes sense and isn't too much trouble.


Fan me up | Twitter l My Website l YouTube (Please Subscribe)

BBS Signature
4urentertainment
4urentertainment
  • Member since: Aug. 1, 2008
  • Offline.
Forum Stats
Moderator
Level 13
Game Developer
Response to Boolean with Arrays? 2013-04-10 16:48:30 Reply

The whole idea of a boolean, is something that only has two states. True or false, 1 or 0.

If you want more, you could simply use an int.

var attackIsSelected:int = 0;

if(attackIsSelected == 0) // is your first state
if(attackIsSelected == 1) // is your second state
if(attackIsSelected == 2) // is your third state

and so on.

Aprime
Aprime
  • Member since: Aug. 15, 2005
  • Offline.
Forum Stats
Member
Level 47
Game Developer
Response to Boolean with Arrays? 2013-04-10 17:01:35 Reply

At 4/10/13 04:48 PM, 4urentertainment wrote: The whole idea of a boolean, is something that only has two states. True or false, 1 or 0.

If you want more, you could simply use an int.

var attackIsSelected:int = 0;

if(attackIsSelected == 0) // is your first state
if(attackIsSelected == 1) // is your second state
if(attackIsSelected == 2) // is your third state

and so on.

That's perfect, thank you very much!

Btw

Is this not possible?

movieClip1_mc.button1_btn.movieClip2_mc.gotoAndStop(1);

I can't seem to get the movieclip inside the button inside the movieclip to gotoAndStop frame 1

How would I go about it?


Fan me up | Twitter l My Website l YouTube (Please Subscribe)

BBS Signature
X-Tender
X-Tender
  • Member since: Aug. 28, 2005
  • Offline.
Forum Stats
Member
Level 05
Game Developer
Response to Boolean with Arrays? 2013-04-11 02:00:59 Reply

Are you sure he's actualy there?
Try some traces like
trace(movieClip1_mc);
trace(movieClip1_mc.button1_btn);
trace(movieClip1_mc.button1_btn.movieClip2_mc);


I code Flash Games! Check out the Stealth Pervert and VOID