This may be an easy question, but I just cannot figure it out.
I was doing one of the tutorials for loading random background images, and I was trying to revise it a bit.
Goal: When the flash starts, a random background image is displayed. The source of the random image is a jpg file contained in an external directory. On an ongoing basis, a non-technical user could just update the files in the directory without changing anything in the flash.
My Problem: I’m having trouble getting the Loader to display a random image to start with. I’ve been trying to use “on(Load)” to call a function that would change the Loader contents, but it doesn’t seem to work.
Here is the code in a frame
// This function works well, and pushes to my bgLoader a background of test1.jpg,
// test2.jpg, or test3.jpg.
function RandomBackground():Void { [INDENT]choice = Math.round(Math.random()*2+1);[/INDENT][INDENT]bgLoader.contentPath = "test" + choice + ".jpg"[/INDENT]};
And here is the code on a movie clip which I was hoping would trigger the loader to load a random image.
onClipEvent(load) {
RandomBackground()
}
The code all validates, but I just get a blank screen. I know it is a problem with my onClipEvent(load) because the following code, placed onto a button, does randomly cycle through the images…
on(press) {
RandomBackground()
}