Random images and preloader

Hi ppl. i am new here and i am learning flash. Can anyone help me with the following:
The challenge:
To make the random image display completely before continuing with the rest of the movie. I want the random image as a background and display the loading progress of the image.

So far:
I have managed to crete random image displays but on theinternet the movies continues on while the image still loading in the background.

The goal:
TO display the random background image completely while showing its loading progress. Only once the image is loaded the rest of the movie can continue.

ANy help would be greatly appreciated.

Thank you.

Load the image into a movieclip.
Monitor the clips bytes loaded, and
if bytesLoaded == bytesTotal, then play on.
Else loop…

footers = 5;
directory = “randomimages/”;
randomswf.loadMovie(directory add Math.ceil(Math.random()*footers) add “.jpg”);
play();

This is the code i have on the second frame on the main stage. I am not sure how to make sure that the random image loads completely before moving on to the next frame.

I am not a programmer, sorry if i seem ignorant about this.

Thank you for any help.