Bitwise arithmentic would be much more appropriate (if I understand correctly)
var CONFIG_A:Number = 1;
var CONFIG_B:Number = 2;
var CONFIG_C:Number = 4;
var CONFIG_D:Number = 8;
So a configuration of A and C would be.
var aAndC:Number = A | C;
To detect config numbers, do the following:
if (configNumber & CONFIG_D) {
// do something to do with D
}
else if (configNumber & CONFIG_B) {
// do something to do with B
}
This is way more extensible, as it's easy to add new configs.
-----Original Message-----
From: [EMAIL PROTECTED] on behalf of eric dolecki
Sent: Tue 3/28/2006 2:44 PM
To: Flashcoders mailing list
Cc:
Subject: [Flashcoders] Architecture opinion...
I'm about to create an uber-class that is basically something that controls
walkthroughs of various situations.
I have configuration states... (sets of three basically)
var CONFIG_1A :Number = 0; // Has item A
var CONFIG_1B:Number = 1; // Has item A and B
var CONFIG_1C:Number = 2; // Has item A and B and C
var CONFIG_2A:Number = 3; // Has item A and D
var CONFIG_2B:Number = 4; // has item A and D and B
... etc. for quite a number of different configuration options. 15 of them
in total.
I am using CONFIG_ for use in if/else statements, etc. but I don't think
this is a very elegant way of doing things. I'd like the code to be readable
& this isn't much better than using simple numerals to set this up. I am
looking for opinions on how to best set this up. Something where if I wanted
to later could add CONFIG_1D and wouldn't have to renumber things. An array
of configs?
Each config setting will have different paths throughout a "tutorial". What
might be the best way to avoid having switches or if/else statements galore
at each step of the process?
Thanks - I know this is a strange request :)
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com