View Full Version : Loading all images in a folder dynamically
jeffsasse
03-17-2004, 06:27 AM
Ok, so I went out and forked up the cash for MX 2004... ouch! Now, how can I dynamically load all images in a specified folder and place each one into an array with a loop so no matter how many images there are, it will load all of them.
Thanks so much for all your help!
Billy T
03-17-2004, 06:46 AM
you will need php or some server side script to return the contents of a directory
for example
<?
/*
Function directory($directory,$filters)
reads the content of $directory, takes the files that apply to $filter
and returns an array of the filenames.
You can specify which files to read, for example
$files = directory(".","jpg,gif");
gets all jpg and gif files in this directory.
$files = directory(".","all");
gets all files.
*/
function directory($dir,$filters){
$handle=opendir($dir);
$files=array();
if ($filters == "all"){while(($file = readdir($handle))!==false){$files[] = $file;}}
if ($filters != "all"){
$filters=explode(",",$filters);
while (($file = readdir($handle))!==false) {
for ($f=0;$f<sizeof($filters);$f++):
$system=explode(".",$file);
if ($system[1] == $filters[$f]){$files[] = $file;}
endfor;
}
}
closedir($handle);
return $files;
}
$images=directory(".","jpg,swf");
?>
jeffsasse
03-17-2004, 12:12 PM
Okay, but how would I implement this into Flash MX? I want to then return the array to the flash program so it may use the array within it specifically and call each image as needed.
jeffsasse
03-17-2004, 12:17 PM
You know what... I think I'm going to just implement a text file where the array will be created manually and placed within flash. I think that is going to be easier for ME, maybe not as easy for the user, but, eh.
Billy T
03-17-2004, 04:53 PM
can load the images array from php using LoadVars
Jon B
03-24-2004, 06:45 PM
if you name all your movies sequentially you can use AS to increment through numbers and load the appropriate movie. Break the loop if flash can't find the number. Not wonderfully efficient, but simple enough.
|
vBulletin® v3.8.3, Copyright ©2000-2009, Jelsoft Enterprises Ltd.