Hello List,
I am currently building an application that uses panels. The Panels
implement a Composite Pattern. The panel holds instances of
panelButtonSets class.
The panel displays certain sets based on a selected item in the client code.
Now my question is, how do I get around a lot of if statements in the
panel like so:
if(clientcode.selecteditem.type == 1){
panel.addSet("position_panel")
panel.addSet("rotation_panel")
panel.addSet("edit_panel")
}else if(clientcode.selecteditem.type == 2){
//different sets of button sets
}
etc...
One solution I am thinking about is the following, but I would like to
get some feedback on this approach.
BasicButtonSet() {
addSets(new panelButtonSets("position_panel"))
addSets(new panelButtonSets("rotation_panel"))
}
ColorButtonSet() extends BasicButtonSet {
addSets(new panelButtonSets("color_panel"))
addSets(new panelButtonSets("brightness_panel"))
}
var basicSet:ButtonSet = new BasicButtonSet();
var colorSet:ButtonSet = new ColorButtonSet();
Then the selected item holds a reference to a certain set that can be
loaded into the panel.
var set = selectItem.GetButtonSet();
Panel.loadSetObject(set )
{
for every set in the parameter set, call its render method and place it
at the right position
};
The thing in this solution is that every set is allready instantiated
and therefore is probably a quit expensive solution?
Jiri
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders