0 Replies Latest reply on Dec 10, 2007 9:28 PM by mcadle

    Array Math

    mcadle Level 1
      What am I missing here? Below is my code. I have an array that I am pushing numbers to. I have a function which loops over the array to add them all up. When you push one item, it works. The second one, nothing displays and you get NaN. What am I missing? Thanks.

      public var prcs:Array=new Array();

      private function calcTot():void
      {
      var ln:uint = prcs.length;
      for(var i:uint; i < ln; i++) {
      subTot=subTot+prcs ;
      }
      }

      This is how I am pushing items:

      prcs.push(grdProds.selectedItem.PRICE);

      Thanks

      EDIT: Nevermind. It was a typing issue. You only need to do this:

      for(var i:uint; i < ln; i++) {
      var tmp:Number=prcs
      ;
      subTot=subTot+tmp;
      }