PDA

View Full Version : Re-reading a directory


spamtheman
03-03-2004, 08:16 AM
Hi

I've got a php file reading a directory of images then i dynamically load these images into flash.
On this page i've got a button which opens a php page in a popup which then allows the user to upload files to the directory and when they're uploaded it confirms it and closes the window, this all works fine.
What i then want to happen is when these files have been uploaded is for flash to re-read the directory and update my image listing
Is there anyway in which i can signal flash to run a script/function/etc... once the php page has done it's job

Regards
Andy

nathanleyton
03-08-2004, 12:08 PM
function login() {
Login = new LoadVars();
Login.username = _root.userName.text;
Login.username = _root.password.text;
Login.onLoad = function(success) {
if (this.auth == 0) {
_root.message.text = this.message;
gotoAndStop("Main", 1);
} else {
_root.message.text = this.message;
stop();
}
};
Login.sendAndLoad("http://localhost/login.php", Login, "POST");
}

Login.onLoad = function(success) {

This will run when you PHP returns succesful
I would reccoment PHPObect for this kind of thing rather than loadVars see www.ghostwire.com

Hope it helps

Nathan

spamtheman
03-08-2004, 12:46 PM
cheers!!

I'll have a look at that PHPObject as well when i get chance, on quick glance that looks like something i could find useful

regards
andy

yubin
03-11-2004, 12:30 PM
How did you get the Flash and PHP to work the image thing dynamically? I'm a newbie and I'm trying to do that very exact thing. Except Mine would be uploaded, I just want to create a dynamic slideshow from the images in a directory.

Any help here would be greatly appreciated.

Yubin:confused:

spamtheman
03-11-2004, 12:38 PM
to read a directory, i just read a php file with LoadVars (or loadVariables)
In the php file i read whats in the directory and then echo it out to an array that flash can read

then i just use a function to loop through the array and use loadMovie to load the images

here's an example of the php:$listfiles = "";
$countfiles = 0;
if ($handle = opendir('../bgimages/thumbs')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && $file != ".DS_Store") {
$listfiles[]=$file;
$countfiles++;
}
}
closedir($handle);
$imagearray = implode(',',$listfiles);
echo "&bgImageArray=" . $imagearray;
echo "&bgCountFiles=" . $countfiles;
}
regards
andy

issamneo
05-20-2004, 06:34 AM
hi
this is for the php parts of the work what about the flash part of the work
thanks

nathanleyton
05-20-2004, 06:47 AM
passing information between flash and PHP is covered in these forums and in the tutorials in great detail. Im sure you with find this if you seach the forum and go through the tutorials.

Nathan