@Zarate is correct that you need to use a server-side scripting language.
If you choose PHP, look into readdir
, which "Returns the filename of the next file from the directory." [PHP Manual]
Here is a PHP class I created for retrieving the filenames of all files in a directory:
class DirectoryContentsHandler
{
private $directory;
private $directoryHandle;
private $dirContents = array();
public function __construct($directory)
{
$this->directory = $directory;
$this->openDirectory();
$this->placeDirFilenamesInArray();
}
public function openDirectory()
{
$this->directoryHandle = opendir($this->directory);
if(!$this->directoryHandle)
{
throw new Exception('opendir() failed in class DirectoryContents at openDirectory().');
}
}
public function placeDirFilenamesInArray()
{
while(false !== ($file = readdir($this->directoryHandle)))
{
if(($file != ".") && ($file != ".."))
{
$this->dirContents[] = $file;
}
}
}
public function getDirFilesAsArray()
{
return $this->dirContents;
}
public function __destruct()
{
closedir($this->directoryHandle);
}
}
Here is how to use the class listed above:
$directoryName = 'some_directory/';
//Instantiate the object and pass the directory's name as an argument
$dirContentsHandler = new DirectoryContentsHandler($directoryName);
//Get the array from the object
$filesArray = $dirContentsHandler->getDirFilesAsArray();
//Display the contents of the array for this example:
var_dump($filesArray);
Beyond that, you could either echo the contents of the array and send them as a string of variables to the SWF, or (this is the better choice if there will by LOTS of images) use PHP to create an XML file that contains the filenames, then send that file to the SWF. From there, use Actionscript to parse the XML, load the image files, and display them on the client's side.