Php array into flash array

Hi guys,

I have this php page that simply reads two items from the db. One is a number and the other is an image name. Now the number is the sequence order of the images. Also it will goven the array number, as the order/sequence of the images are random and following nothing easy, and I cannot alter the db, so using this sequence number I have place the images in an array, using the sequence to order correctly see below:

while($row = mysql_fetch_array($result)) {

$theImages[$row[‘sequence’]]=$row[‘img’];

then when i echo these out normally for testing using a for loop see below I get them into the correct order as wanted:

for($i=0; $i<22; $i++){
echo ‘<br /><br /><img src="directory/’ . $theImages[$i+1].’" />’;
echo ‘<br />’ . $theImages[$i+1];
}

Right now I can get data into flash no problem say like news stories ect but what I want to do here is to place these into a flash array so I can create a simple gallery, that will use the array to go back and forth through the images.

How could I get the info into a flash array to I can manage it with in flash actionscript etc

I hope this is enough info.

Si

Parse your PHP into an XML structure, then read that into Flash and parse it back out. It may feel like a little more work, but it will at least keep things clean and structured. Anything like splitting strings is going to be slow, especially if you have a lot of data to work with.

I did something similar but I was making a 2-d RPG game and my levels were arrays.

What I did, since my levels were simply numbers, is I added a line separator and a number separator.
My format was like
1$2$3$4…$9|
123$456$789|

Then I just split the strings in Flash because when you split a string it automatically makes an array…
quick as hell and perfect.

thanks guys, decided to go with the xml version and go into that direction, will post up my solution if working for others or simply another problem question :slight_smile:

si