?
Solved

Sum an Array for Preloader of Images

Posted on 2005-03-17
5
Medium Priority
?
145 Views
Last Modified: 2012-05-05
onClipEvent(load) {

myResult=0;
sumArray = new Array();

}
onClipEvent(enterFrame) {
for (d=0; d < _root.numberOfQuestions; d++) {
this["imageBytesLoadedSum"+d] = _root.score.imageHolder["image" + d].jpg.getBytesLoaded();
sumArray[d] = this["imageBytesLoadedSum"+d];

myResult += sumArray[d];
trace(myResult);  //  Traces as NaN
trace(sumArray[d]) // Report the bytes loaded okay.
}

}

In the above, I expected "myResult"  to add up the contents of the array called sumArray. Instead, it report NaN.  How can I sum the bytesloaded in the above scenario?  Thanks.

0
Comment
Question by:Aspirin99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 18

Accepted Solution

by:
Billystyx earned 2000 total points
ID: 13566916
what is supposed to be in you sumArray?
It looks like nothing is there. Is this the line that is meant to add to the array?
sumArray[d] = this["imageBytesLoadedSum"+d];
.
You add to an array by myArr.push(value);

getBytesLoaded increments as the movieclip loads - why are you summing it?
Billystyx
0
 
LVL 1

Author Comment

by:Aspirin99
ID: 13567011
for (d=0; d < _root.numberOfQuestions; d++) {
this["imageBytesLoadedSum"+d] = _root.score.imageHolder["image" + d].jpg.getBytesLoaded();
sumArray[d] = this["imageBytesLoadedSum"+d]; //<--------------------- Right here I'm grabbing the bytes total.

Gettting the bytes total is working fine. I don't want to push to the array because that would create a new array item each push. I only want as many array items as I indicate in the for loop. As to what I'm summing it, I want to add the bytes total for all the images I'm loading. The code has to accomodate a different number of images each time.
0
 
LVL 1

Author Comment

by:Aspirin99
ID: 13567382
I figured it out.

if (typeof(sumArray[d])=="number") {
myResult = myResult + sumArray[d];
}
0
 
LVL 18

Expert Comment

by:Billystyx
ID: 13567947
Good work and good luck!
Billystyx
0
 
LVL 1

Author Comment

by:Aspirin99
ID: 15411034
I awarding points to Billystyx just to close this - and because he's helped me a few times.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question