# Loading contents from randomized array sequentially

**URL:** <https://forum.kirupa.com/t/loading-contents-from-randomized-array-sequentially/151692>\
**Category:** Uncategorized\
**Created:** [June 17, 2005, 9:20am UTC](https://forum.kirupa.com/t/loading-contents-from-randomized-array-sequentially/151692 "2005-06-17T09:20:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![imported\_Mrrufus](https://avatars.discourse-cdn.com/v4/letter/i/e95f7d/32.png) [@imported\_Mrrufus](https://forum.kirupa.com/u/imported_Mrrufus)\
**Post date:** [June 17, 2005, 9:20am UTC](https://forum.kirupa.com/t/loading-contents-from-randomized-array-sequentially/151692/1 "2005-06-17T09:20:21Z")

</div>

Hi there,

I have this function which randomizes an array loaded from a text file that contains the names of folders that contain the content to be loaded. The problem is that all the content is preloaded at once (12 thumbnail-sized swf’s, that in turn load images), before it displays it in Flash. How would I go about displaying each image as soon as it is loaded, while the rest are still being loaded?  
Here’s the code I have:

First frame:  
[AS]  
stop();  
toArray = new Array();  
my\_var = new LoadVars();  
my\_var.onLoad = function(success) {  
if (success) {  
toArray = this.toArray.split(",");  
gotoAndPlay(2);  
}  
};  
my\_var.load(“content/inspiration/inspirationContents.txt”);  
[/AS]

Second Frame:  
[AS]  
randomNumArr = [];  
for (i=0; i\<12; i++) {  
randomNumArr.push(i);  
}  
addContent = function (clipNum) {  
var ranNum = Math.floor(Math.random()\*(randomNumArr.length));  
this[“daThumb\_”+clipNum].daImageTarget.loadMovie(“content/inspiration/”+toArray[randomNumArr[ranNum]]+"/preview/loadThumb.swf");  
randomNumArr.splice(ranNum, 1);  
};  
[/AS]

And then on the third Frame I add all the contents:  
[AS]  
addContent(1);  
addContent(2);  
addContent(3);  
.  
.  
.  
addContent(12);  
stop();  
[/AS]

Any input is really appreciated!!

Thanks,

Rufus
