Thank you for the reply. I will take a look at the state Pattern.
Reading your post, I does look a bit like what I proposed. In the state
pattern, I would probably create the layout and the types of buttonsets
for the panel create in a object. The state of the panel then determines
wich state to load and display using composition.
Did I understand your comment correctly?
Jiri
Raymond Simmons wrote:
Jiri,
Sounds like the state pattern would be helpful here. Define a class for
each state of the application. Each class will contain methods for
actions the user can take in that state, like selectListItem. When the
user takes the given action (ex., selecting a list item), the associated
function in the current state is called, and the correct actions are
performed. Once those actions are performed, move the application to
the new state. Essentially the current state class decides what actions
to take in response to user interaction with the application.
Thanks,
Raymond Simmons
----- Original Message ----- From: "Jiri Heitlager"
<[EMAIL PROTECTED]>
To: "Flash Coders List" <[email protected]>
Sent: Tuesday, April 01, 2008 6:03 AM
Subject: [Flashcoders] Some feedback on a coding design question
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
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders