1 Reply Latest reply on Feb 21, 2008 9:36 PM by Gregory Lafrance

    ArrayCollection - Value1 + Value2 = Value 3

    breez11 Level 1
      I have a csv file which gets loaded then parsed. The parsed data consists of 2 number values. The values are currently being added to an arraycollection.

      I would like to create a third value which would be the percentage of value 1 to value 2 and have that added to the arraycollection with the rest of the data.

      How can I acheive this? Can this be done after the arraycollection is define? Any insight will be highly appreciated.
        • 1. Re: ArrayCollection - Value1 + Value2 = Value 3
          Gregory Lafrance Level 6
          <?xml version="1.0"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="init()">
          import mx.collections.ArrayCollection;

          public var ac:ArrayCollection = new ArrayCollection();

          public function addData():void {
          var obj:Object = new Object();
          obj.val1 = Number(txt1.text);
          obj.val2 = Number(txt2.text);
          obj.tot = (Number(txt1.text) + Number(txt2.text));

          public function init():void{
          <mx:Button label="Get Data" click="addData()"/>
          <mx:TextInput id="txt1" text="0"/>
          <mx:TextInput id="txt2" text="0"/>
          <mx:DataGrid id="dg" dataProvider="{ac}" width="300" height="300"/>