Hi,

>                               for (var i:int = 0; i < length; i++) {   /*  
> Loop Through Each of the
> Records*/
>                                       if (tempArray[i].status == "Act") { /*  
> Test to see if current record
> status is ACTIVE */

String comparisons are slow, try to make this numeric if you can.

>                                               for (var j:int = 0; j < length; 
> j++){  /*  Compare to Each of the
> other Records*/

Should be able to go from i+1 to j in this loop so you don’t do the same 
calculations twice. (That will make it run twice as fast.)

>                                                       if (i != j) {   /*  
> Make sure you are not comparing a record to itself

If you change the loop above no need for this.

> */
>                                                               if 
> (tempArray[i].propOne == tempArray[j].propOne) { 

Creating  var itemA:Object = tempArray[i] and var itemB:Object = tempArray[j] 
rather than looking them up every time may be faster. Use itemA and itemB where 
you have tempArray below. Also makes code a little more readable.

>                                                                       if 
> (tempArray[i].propTwo == tempArray[j].propTwo) {
>                                                                               
> if (tempArray[i].propThree == tempArray[j].propThree) { 
>                                                                               
>         if (Math.abs(tempArray[i].propFour - tempArray[j].propFour) <=
> 10) { 
>                                                                               
>                 if (tempArray[i].propFive == tempArray[j].propFive) { 
>                                                                               
>                         if (Math.abs(tempArray[i].propSix - 
> tempArray[j].propSix) <= 1)
> { 
>                                                                               
>                                 if (Math.abs(tempArray[i].propSeven - 
> tempArray[j].propSeven)
> <= 1) { 
>                                                                               
>                                         if (Math.abs(((tempArray[i].propEight 
> -
> tempArray[j].propEight)/tempArray[i].propEight))<0.10) {
>                                                                               
>                                                 lon1 = 
> tempArray[i].longitude*Math.PI/180;
>                                                                               
>                                                 lon2 = 
> tempArray[j].longitude*Math.PI/180;
>                                                                               
>                                                 lat1 = 
> tempArray[i].latitude*Math.PI/180;
>                                                                               
>                                                 lat2 = 
> tempArray[j].latitude*Math.PI/180;
>                                                                               
>                                                 dlon = lon2 - lon1;
>                                                                               
>                                                 dlat = lat2 - lat1;
>                                                                               
>                                                 a = 
> Math.pow(Math.sin(dlat/2), 2) +
> (Math.cos(lat1)*Math.cos(lat2)*Math.pow(Math.sin(dlon/2), 2));
>                                                                               
>                                                 c = 
> 2*Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
>                                                                               
>                                                 d = 3961 * c;
>                                                                               
>                                                 
>                                                                               
>                                                 if (d <= tempDistance ) {
>                                                                               
>                                                         count = count + 1;
>                                                                               
>                                                         someProp = someProp + 
> Number(tempArray[j].propEleven);
>                                                                               
>                                                         tempCompArray.push({" 
> push about 26 properties from one
> array to a comparison array, plus some new values});
>                                                                               
>                                                         
> tempArray[i].propTwelve = is true;

istrue? Is that a string or a number or boolean?

>                                                                               
>                                                 }
>                                                                               
>                                         }
>                                                                               
>                                 }
>                                                                               
>                         }
>                                                                               
>                 }
>                                                                               
>         }
>                                                                               
> }
>                                                                       }
>                                                               }
>                                                       }                       
>                         
>                                               }
>                                               
>                                               if (count != 0) {               
>                                                                         /*  
> Populate data if there is actually
> data to be updated */
>                                                       average = 
> someProp/Number(count);

Note sure you need a cast to Number here?

>                                                       
> tempArray[i].propThirteen = count;
>                                                       tempArray[i].Prop14 = 
> average;
>                                                       
>                                                       if (average == 0.0) {

May be a issue with numbers close to 0, rounding issues etc etc here, typically 
something like if (average <= 0.00001) is used.

>                                                               
> tempArray[i].propFourteen = 0.0;
>                                                       } else {
>                                                               
> tempArray[i].propFourteen = (Number(tempArray[i].propTen) -
> average)/average *100.0;
>                                                       }
>                                                       
>                                                       
> tempArray[i].propFifteen = tempArray[i].propFourteen -
> tempArray[i].propFifteen;
>                                               }
>                                               
>                                               count = 0;
>                                               average = 0.0;
>                                               someNumber = 0.0;
>                                       }
>                               }
>                               
>                               PopUpManager.removePopUp(processingPU);
>                               compArrayCollection.source = tempCompArray;
>                               mainArrayCollection.source = tempArray;
>                               
>                    }

Hope that helps,
Justin

Reply via email to