Looping functions problem, it just skips to the last instance

Hello All,

I am using Actionscript and the problem I am having is the I am running a for loop to execute a function which loads the variables from XML and then another function to load an external SWF which will load the variables from the first function. Here is the code snippet

for(i=0;i<2;i++) {
createproduct();
displayproduct();
}

Currently, createproduct will create a series of arrays with the new data. The displayproduct() function pushes the data out into a image loader. However, my guess is that the loop is executed so quickly, that the data becomes the last instance in the for loop and therefore displays the same(last instance) data for both displayproduct function. Is there any way to have a function wait till the previous function completes? That way when I fun the script, it will show up 2 instances of the image loader with the appropriate data. Thank you in advance!

-Ivan

nope its because you are not incrementing “i” to the functions

you should really have

createproduction(i)

in short you are running the code, the for loop gets to 2, and your stuck with that, because you didn’t increment the other files

also you are loading into separate MCs? noob mistake but it pops up a lot

Hello, Thanks for the help, however, it still doesn’t show the first data for the loop. The displayproduct function basically calls an external swf file which will pull out the data associated with the createproduct function (which creates an array of data). Is there a way to have the createproduct function to wait until the displayproduct function completes? Thanks again!

-ivan

yes. all you have to do is call the createproduct function in the end of the display function, instead of calling it in the cicle.

be aware of the “i”. dont forget to tell the create product function wich product is suposed to appear