Loading random backgrounds

In this one, I'm going to show you how to load random backgrounds when pressing on a menu item.

Step 1

First of all we gotta make our variable pObject visible everywhere inside the AS code. We will use it later. So, on line 507 (under XMLParser.load("backgrounds.xml",onF);) insert this codeline:
var pObject:Object;

Step 2

Now we will get a random number between 0 and our backgrounds.xml node length and load that background on start. Paste this code on line 520 and 521:
randbg = Math.round((Math.random())*(pObject.q.length - 1));
loadbg(pObject.q[randbg].bg[0].value,mc_bg);

Step 3

We will use the same code for each of our menu levels. As you already know, there are 3 menu levels. So, paste the same code on each level. Take a look at the pictures:
randbg = Math.round((Math.random())*(pObject.q.length - 1));
loadbg(pObject.q[randbg].bg[0].value,mc_bg);





That's all! Now test your movie.