PDA

View Full Version : General Action Scripting Loops, comparisons, loadMovie



kguerrero
02-08-2006, 01:15 AM
I have been struggling with a preloader for a slideshow for some time.

Below is the code which I use to load images into my slide show. The action scirpting is isolated on the upper most layer in the flash file.

I have added "trace" statements to help me trouble shoot. I have been troubleshooting one step at a time and I think I have found an issue. But I don't know the cause.

In the output window the first trace statement yields the correct value for i starting with 0.

In the output window the second trace statement yields the correct value for image file and location derived from the xml file.

In the output window the third trace statement yields the correct value for movie clip instance name derived from the data set included at this level of code.

Now this is what I don't understand

The next variable: sI. Ask to be assigned the value of the File size of the movie clip.

The trace step outputs the value of sI. I receive an "undefined". In order to due a proper preloader I need to compare the file size to the amount loaded. I have run experiments and file loaded also yields an "undefined" value. Comparing the two values always equals out. So, the preloader doesn't work, since logic statements are written to evaluate the difference between file size and amount loaded.

My question is: why do I receive the value of undefined?

function loadXML(loaded)
{
xmlNode = this.firstChild;
image = [];
size=[]
loaded=[]
myInstance = ["Image 1","Image 2","Image 3","Image 4","Image 5","Image 6","Image 7","Image 8","Image 9","Image 10","Image 11","Image 12","Image 13","Image 14","Image 15","Image 16","Image 17","Image 18","Image 19","Image 20","Image 21","Image 22","Image 23","Image 24","Image 25"]
total = xmlNode.childNodes.length;
for (i = 0; i < total; i++)
{
trace(i);
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
trace(image[i]);
loadMovie(image[i],myInstance[i]);
trace(myInstance[i]);
sI = myInstance[i].getBytesTotal();
trace(sI);
} // end of for
} // End of the function
images="images.xml"
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load(images);
xmlNode = this.firstChild;

kguerrero
02-19-2006, 01:34 PM
I decided to post a response to my own post with the results I discovered.

1. How valuable the debugger window is.
2. Avoid Movie Clip Instance names that are two or more words (i.e have a space in the name).

I did manage to get the size value however I am not able to use nice variables and arrays.

Through the debugger window I noticed that my movie clips were loaded to _level0.

by adding: si=_level0.image1.getBytesTotal(); I am able to actually get the size.

I don't understand why variable arrays do not work for this function but I am able to use my preloader now ... and that all that counts.

Thanks