Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 03-17-2004, 07:27 AM   #1
jeffsasse
Registered User
 
Join Date: Feb 2004
Location: Washington
Posts: 8
Default Loading all images in a folder dynamically

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!
jeffsasse is offline   Reply With Quote
Old 03-17-2004, 07:46 AM   #2
Billy T
Oops I did it again
 
Billy T's Avatar
 
Join Date: Oct 2001
Location: Melbourne
Posts: 8,578
Default

you will need php or some server side script to return the contents of a directory

for example

PHP Code:
<?
/*
        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");
?>
__________________
Billy
Online Galleries
Free Flash Video Tutorials
Photo Website Template

Don't email or PM me questions...
Billy T is offline   Reply With Quote
Old 03-17-2004, 01:12 PM   #3
jeffsasse
Registered User
 
Join Date: Feb 2004
Location: Washington
Posts: 8
Default

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 is offline   Reply With Quote
Old 03-17-2004, 01:17 PM   #4
jeffsasse
Registered User
 
Join Date: Feb 2004
Location: Washington
Posts: 8
Default

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.
jeffsasse is offline   Reply With Quote
Old 03-17-2004, 05:53 PM   #5
Billy T
Oops I did it again
 
Billy T's Avatar
 
Join Date: Oct 2001
Location: Melbourne
Posts: 8,578
Default

can load the images array from php using LoadVars
__________________
Billy
Online Galleries
Free Flash Video Tutorials
Photo Website Template

Don't email or PM me questions...
Billy T is offline   Reply With Quote
Old 03-24-2004, 07:45 PM   #6
Jon B
Gloomy
 
Jon B's Avatar
 
Join Date: Sep 2002
Location: Newcastle Upon Tyne, UK
Posts: 180
Default

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.
Jon B is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:58 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.