2 Replies Latest reply on Jul 8, 2010 8:30 AM by Fred in Orlando

    How to get static attribute using it's name as a string

    Fred in Orlando

      I have an app with about 100 unique combo boxes (it's a gov't requirement, I'm not that bad a designer ) and I would like to define all the choices in a single separate file like this:


      package components {


      import mx.collections.ArrayCollection;


          public class Choices    {


        [Bindable] public static var A0310A:ArrayCollection = new ArrayCollection ( [
                                            { value:"01", label:"Admission"},
                                            { value:"02", label:"Quarterly" },   
                                       ........snip ..
                                            { value:"99", label:"NOT OBRA Required" }]);
                public static function getChoices(name:String):ArrayCollection {
                    var temp:ArrayCollection = ????????????????
                    return temp;
          }//----------------end of class--------------------------------
      }//======================== end of package==============================


      I want to use it like this


      <my:ComboBox id="mdscombo" tag="A0310A" />


      Where the definition of my:ComboBox includes code like this


                   var zz:ArrayCollection = Choices.getChoices(name);


      but I cannot find any function that will let me do this.  I really don't want to clutter the code by creating a name->object lookup table.


      I had also considered using the XML data type but I would have the same issue unless I had all the choices under a single root (possible) but that could be a nightmare in debugging typo's in the XML.


      Any suggestions???