# Randomizng an XML Array and Timing

**URL:** <https://forum.kirupa.com/t/randomizng-an-xml-array-and-timing/71984>\
**Category:** flash\
**Created:** [December 1, 2004, 7:12am UTC](https://forum.kirupa.com/t/randomizng-an-xml-array-and-timing/71984 "2004-12-01T07:12:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![misterpatrick](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@misterpatrick](https://forum.kirupa.com/u/misterpatrick)\
**Post date:** [December 1, 2004, 7:12am UTC](https://forum.kirupa.com/t/randomizng-an-xml-array-and-timing/71984/1 "2004-12-01T07:12:26Z")

</div>

Hello all,

I’ve gone through the XML and Flash PhotoGallery tutorial but am having some trouble adopting something. I’d like to figure out a way to randomly choose something from the XML array and load that image after 10 seconds. I’ve looked all over but can’t find what I am looking for.

Here are the two functions. I am having problems incorporating the two.

Array.prototype.randomize = function() {  
for (var j=this.length-1; j\>0; j–) {  
var pick = random(j);  
var tmp = this[pick];  
this[pick] = this[j];  
this[j] = tmp;  
}  
};

function firstImage() {  
if (loaded == filesize) {  
picture.\_alpha = 0;  
picture.loadMovie(image[0], 1);  
}  
}

So it seems I want the image to load a varaible that equals a random number pulled from the array ‘total’ which is derived from orginal xmlLoad code. Say, ‘r’.

picture.loadMovie(image[r], 1);

I have messed around with variations of creating r my calling the randomize function but with no luck. What am I doing wrong?

Needless to say, I am not very good at AS.

OK, my other problem is then incorporating the timing portion. Is it just embedding the firstImage function in a loop of something? Again, feel free to just point me to a good toturial I can mess with. Once I’m on the right trail I can usually figure things out.

Thanks!

-Patrick
