To answer having switch statements and if/else statements galore, options
behaviors that're determined by other options being active or inactive
should be combined into a single option. This should account to a collection
of options absolutey decoupled from one another. If this is already the
case, being, all options do not depend on each others states to enforce
their behaviors, then I have a suggestion that should lend itself to bit
switches.

Each option should be a class of its own, taking the current pages clip as
an argument to a decorative function which would design the options behavior
into the page.

The application would sequence as so:

The options would be set and stored in an array, the order should not matter
since the options are decoupled from each other. When a new page is
navigated to, the navigator would pass the page to a function which would
propogate the page to a common function which each option would use to take
and identify the page to be decorated with that options behavior. All
options could extend, or be composed with, a base option class which would
account for the common functionality each option would share, such as
decorating pages.

The idea is to swap the conditions from the pages logic over to the options
logic, you could take from the idea of this and maintain the conditions
driven by the options if there are less options than pages.

In a rough outline in code, it might resemble this:

Class OptionBase {

var pageA:Function; //to be defined in extending class

function OptionBase(){
}

function decoratePage(page:MovieClip, pageID:String){
switch(pageID){
case 'pageA': pageA(page); break;
}

}

//...
}


Class OptionA extends OptionBase {
//...
function pageA(pageA:MovieClip){
//mangle pageA in every which way.
}
//...
}

There might be a manager class that does managerial things.

Good luck,

M

On 3/28/06, eric dolecki <[EMAIL PROTECTED]> wrote:
>
> 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

Reply via email to