# Upgrading this code to AS2?

**URL:** <https://forum.kirupa.com/t/upgrading-this-code-to-as2/236126>\
**Category:** Uncategorized\
**Created:** [August 17, 2007, 1:01pm UTC](https://forum.kirupa.com/t/upgrading-this-code-to-as2/236126 "2007-08-17T13:01:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![boozy\_juice](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@boozy\_juice](https://forum.kirupa.com/u/boozy_juice)\
**Post date:** [August 17, 2007, 1:01pm UTC](https://forum.kirupa.com/t/upgrading-this-code-to-as2/236126/1 "2007-08-17T13:01:17Z")

</div>

hello all, im playing with the load random movie (but loading a random xml file instead) based on the wonderful tutorial from front page and was wondering whether anyone can show me the work around/upgrade to AS2 for this bit of script since im publishing to Flash 8 /AS2 and it doesnt work:

```auto

filename = ["gallery.xml", "gallery01.xml", "gallery02.xml", "gallery03.xml", "gallery04.xml"];
path = "http://www..co.uk/";
i = filename.length;
k = Math.floor(Math.random()*i);
xml.load(path+filename[k]);

```

yet if i drop the ranodm code up there and simply put this code per each xml file they load individually ok

```auto
xml.load("gallery01.xml");

```

all i want to achieve is to load any random one of ‘X’ amount of images via an XML sheet, so ive spread each ordered list across 5 different linear (top down) XML files - each one loaded randomly, giving the impression that the flash file loads a random image each time.

i know its a long work around but where am i going wrong?

thank you
