Same theory, different implementation. I do same thing to calculate totals of 
values like so:

public function calculateTotals():void
   {
    var data:ArrayCollection = dataProvider;
    var i:Number, credit:Number=0, debit:Number=0;
    for (i=0;i<data.length;i++){
     credit += data[i].credit;
     debit += data[i].debit;
    }
    totalCredit.text = moneyFormatter.format(credit);
    totalDebit.text = moneyFormatter.format(debit);
   }


Cheers,
Adam

  ----- Original Message ----- 
  From: Mehul Doshi 
  To: [email protected] 
  Sent: Thursday, March 01, 2007 9:09 AM
  Subject: [flexcoders] Re: ArrayCollection length


  Hey,

  This actually doesn't work. Your logic seems to simply count the 
  number of elements in the arraycollection. I'm trynig to figure out 
  the number of items in the first element of the collection.

  Thanks.

  --- In [email protected], "iilsley" <[EMAIL PROTECTED]> wrote:
  >
  > --- In [email protected], "Mehul Doshi" <Mehul.Doshi@> 
  wrote:
  > >
  > > 
  > > If I have my dataprovider in the following manner:
  > > 
  > > var dataProvider = [{Date: "02-12-2007", Company1: 20, Company2: 
  30},
  > > {Date: "02-09-2007", Company1: 20, Company2: 30},
  > > {Date: "02-08-2007", Company1: 20, Company2: 30}]
  > > 
  > > How can I determine programatically:
  > > 
  > > 1. The number of companies.
  > > I dont't seem to be able to figure out how to find the number 
  of 
  > > items in a particular element of the ArrayCollection.
  > 
  > 
  > Hi , 
  > 
  > I'm a newbie to Flex2 so there is probably a better way todo this 
  but 
  > for now this seems to work .. :) .. 
  > 
  > -----
  > public var con:ArrayCollection = 
  > new ArrayCollection([{name: 'Matt', last: 'Matthews'}
  > ,{first: 'Matt', last: 'Smith'}
  > ,{first: 'Albert', last: 'Jones'}]
  > );
  > 
  > public function howManyFirstelements():void
  > {
  > var fst:int =0;
  > for ( x=0 ; x < con.length ; x++ ) 
  > {
  > if ( con[x].hasOwnProperty("first") == true) 
  > {
  > fst++;
  > }
  > }
  > Alert.show("There are "+fst+" first elements ");
  > }
  > ----
  >



   

Reply via email to