PDA

View Full Version : PHP and action script - Random Search



unclesond
January 6th, 2005, 12:46 PM
I posted an earlier question regarding the in the Flash MX forum with some joy, but now my question is purely AS. I'm very new to AS, and even newer to PHP

Firstly I aim to load random jpgs into a movieclip from a folder online. online image dir (http://www.cppa.co.uk/t/images/) As jpgs will be constantly added to this by anyone, I will never know the file.jpg names to put into my AS.

So i was advised I needed PHP to do this, (I know little about PHP) I got some space where PHP works! PHP enabled (http://www.cppa.co.uk/t/info.php)

Right so at the moment I have a Movie Clip in flash with a piece of AS that says
onClipEvent (load) {
loadVariables("http://www.cppa.co.uk/t/test1.php", this, "GET");
filenames.split(":");
myRandom = random(filenames.length);
key1.loadMovie(filenames[myRandom]);
}


this should start looking at my piece of PHP and then retreive the required filenames

obviously the web address above links to this bit of PHP address (http://www.cppa.co.uk/t/test1.php)

This is the php script it use to get the file names inside the "images" folder


<?PHP
$dir = "c:\websites\free\crystal\www\t\images\";
$handle = opendir($dir);
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$filenames .= $file.":";
}
}
closedir($handle);
echo "&filenames=".$filenames;
?>

But when trying my php file through firefox its says (php file

"Parse error: parse error, unexpected '.' in c:\websites\free\crystal\www\t\test1.php on line 5"

So if anyone could give me any advice on how to make this piece of PHP script send the flash the filenames of the directory, so flash can random insert on into a movie clip, it would be great!

Also is my bit of AS correct?

if you need my fla, just say.

Thanks in advance

senocular
January 6th, 2005, 12:52 PM
ok, I didnt read your post but from the php script posted, I noticed you havent escaped yout \ slashes. Use \\ to represent one \. Since \ is used for escaping, it itself needs to be escaped