(This is a fundamental question, and it' challenging to find a clear
way to ask it):

Let's say I have an ArrayCollection data source with 50 fields (which
I do), and my user selects the name of one of these fields (let's say
"PRODUCT") with myComboBox, so that it's now in
"myComboBox.selectedItem.data".

How can I make actionScript use this value dynamically, so that
instead of coding a switch with 50 cases for each property like so:

switch(myComboBox.selectedItem.data){
 case "PRODUCT":
   return item.PRODUCT;
   break;
 case "FIELD2":
   return item.FIELD2;
   break;
 case "FIELD3":
   return item.FIELD3;
   break;
...
}

? Can I can instead do something like
"item.[myComboBox.selectedItem.data]"?  Do you know what I mean? 
Something like
"item.getValueofNamedProperty(myComboBox.selectedItem.data);".

[Without complicating the question, I ask because this would greatly
simplify a complex charting component I'm developing, where the user
should be able to summarize the underlying data based on any of the
fields; so I need to know the selected property for the filter
function, the toolTip, the sort function, etc.  Right now I'm only
supporting 3 properties, since I'm relying on nested switch statements
like the one above].

Hopefully I'm just missing a really basic piece of actionScript
syntax.  Many thanks for any suggestions!

-Peter Demling
 Lexington, MA

Reply via email to