4 Replies Latest reply on May 5, 2010 8:58 PM by megharajdeepak

    How to use static const variable while looping ArrayCollection?

    megharajdeepak Level 1


      I have a arraycollection which I get from backend system, which has two columns named, 'Id' and 'Desc'.


      I have created a static const variable:

      public static const FIELD_DESC_NAME:String = "Desc";


      I have been using this const variable in all the places in my code, for example:


      super.dataProvider = model.acVariants;
      super.labelField = FIELD_DESC_NAME;  // instead of using, super.labelField = "Desc";


      But unfortunately, there is one place where I am not able to use it. And that is while looping the array as shown below:


      for(var i:uint=0;i<model.acVariants.length;i++){

                 if(value.label == model.acVariants[i].Desc){               // I want to use the variable  FIELD_DESC_NAME, instead of using 'Desc' in model.acVariants[i].Desc 
                         super.selectedItem = model.acVariants[i];



      Can you please let me know how can we achieve this?


      Appreciate your help....