|
-
dynamic loading of all images in a folder
------Flash MX 2004 Pro------
Is there a simple(?) way to auto- and dynamicaly load all images in a specific folder with, for example, your holliday images. My images names are auto generated by my digital camera and looks like this:
IMG_0134.JPG
IMG_0135.JPG
IMG_0142.JPG
IMG_0144.JPG
The best thing would be if some code could load all images in a folder irrespective of the file names (my_image_1a.jpg, myCat.jpg, IMG_0134.jpg, IMG_04.jpg etc.)
Please help me. I don't want to manualy write a long list, xml or similar
Thanx
-
Senior Member
If you have PHP installed on your server you could use that to read the content of the directory and return a list of files to the flash movie.
I think something like this should work,
PHP Code:
<?php
$dir = 'path/to/the/directory';
$numfiles = 0;
if (is_dir($dir)) {
if ($openDir = opendir($dir)) {
while (false !== ($file = readdir($openDir))) {
if ($file != '.' && $file != '..') {
if (is_file($dir . '/' . $file)) {
$f = explode('.', $file);
$ext = array_pop($f);
if ($ext == 'jpg') {
echo "&filename$numfiles=$file";
++$numfiles;
}
}
}
}
}
closedir($openDir);
}
?>
which could be run using the LoadVars object, and would return variables named filename0, filename1 etc...
Code:
var lv = new LoadVars();
lv.onLoad = function(ok) {
if (ok) {
var i = 0;
// loop through the loaded variables
while (this["filename" + i] != undefined) {
trace(this["filename" + i]);
++i;
}
}
};
lv.load("your_php_script.php");
-
Thanx
Thanx, that works too.
But the thing I realy wanted was to do this directly from Flash, but I don't think it's possible, after looking around on different forum's. Then your solution must be the best, i guess?!
/bnet
-
Senior Member
I think the best you can do directly from flash is to check to see if a file exists,
http://www.flashguru.co.uk/checking_...ile_exists.php
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|