Dynamic Slideshow

I am new to flash I will tell you that up front. What I am trying to do is make a dynamically created slideshow. I have a database with the filenames located in a field. Using PHP I am able to query the DB and get the filenames. Now comes the part where I am having trouble. I will try to explain this as best as I can.

I am using Flash MX.

On my stage I have a movie clip with the name slideshow. The following code are the Actions for slideshow on the stage.


onClipEvent (load) {
stop();
loadVariables("slideshow.php", this);
SlideNum = 0;
play();
}

Okay from what I understand this will allow me to get variables from slideshow.php. In the movie clip slideshow I have another movie clip with the name animatedSlide. The following is the actionscript for the instace of animator (Instance of animatedSlide). I would like to use the variable or array name filename and call each instance of the array using SlideNum which is basically a counter.


animator.createEmptyMovieClip("slide", 0);
loadMovie("pictures/"+filename[SlideNum], animator.slide);
if (SlideNum == maxImages-1) {
SlideNum = 0;
} else {
SlideNum++;
}

The slideshow.php is as follows minus the correct structure of how to get my array of filenames to flash to use.


include("db.php");	// CONNECT TO DB
db_connect($db_hostname, $db_username, $db_password,$db_database);
$select = mysql_query("SELECT * FROM pictures WHERE pic_active='1'");
$max = mysql_num_rows($select);
$i = 0;
while($row = mysql_fetch_array($select))
{
	 $filename[$i] = $row['pic_filename'];
	 $i++;
} 
## SET FLASH VARIABLES UP HERE ##
echo "maxImages=$max&cap=capped";

If anybody can please help I would be more than happy to show screenshots of my flash file or allow anybody who thinks they can help I will give you the link to test it out.

TIA,
Mitt