Skip to main content
May 26, 2009
Question

Binding ArrayCollection items to vars

  • May 26, 2009
  • 1 reply
  • 548 views

Hi there,

I have an arrayCollection that is populating a chart. Can I bind the array items to vars that I can then modify?

         private var ratingAC:ArrayCollection = new ArrayCollection([
         { Rating: 10 }, // [0] positive
         { Rating: 20 }, // [1] neutral
         { Rating: 60 }  // [2] negative
         ]);

Rating Variables

private var positive:int = 0;
         private var neutral:int = 0;
         private var negative:int = 0;

Loop to update the arrayCollection

   private function buildChart():void{
             for(var i:int; i<newsDB.length; i++){
                  if(newsDB.rateItem == 0){
                       ratingAC.addItemAt(); // how can i add 1 to the value at index[0]?
                  }
                  if(newsDB.rateItem == 1){
                       neutral += 1;
                  }
                  if(newsDB.rateItem == 2){
                       negative += 1;
                  }
                  
             }
        }

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
May 26, 2009

is this for flex?

May 26, 2009

Yes. I posted in the wrong forum, sorry!

kglad
Community Expert
Community Expert
May 26, 2009

np.