-
I need help Manipulating an array
I have an array declare on my main time line named W_time in it i have several numbers.
now what i want to do is add this numbers in the array together so i can have a sum, then i want to find the average for this numbers, am usint this code to find it, but it returns NaN....
for(i = 0; i < 10; i++){
sum += W_time[i];
}
myAverage = sum / 10;
does this work or is there another way to add an array. Pls help.......
Last edited by flash_ee2; 02-19-2005 at 04:56 PM.
Post no bills
-
Senior Member
Hi,
Do you use mx2004? if so you need to make sure you set sum to zero before you start the loop,
Code:
sum = 0;
for(i = 0; i < 10; i++){
sum += W_time[i];
}
myAverage = sum / 10;
using += on an undefined variable won't work in mx2004 (but was ok in previous versions where actionscript was a little less strict)
-
Thx i would not had figure that out since i have been using flash for a while and now switch to 2004 is pain to make the transition....by the way it worked....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|