Is it possible?

Hello

I was wondering if it’s possible from flash to check for files at the same level as where the flash movie is. I was thinking of making a dynamic playlist depending on what mp3 there’s on the webserver in the same dir as the movie.swf.

Can anyone guide me? Is it possible?

Hmm… I’m not too sure about Flash being able to read directory structures (but I definatly don’t know everything about flash).

My suggestion would be to use your favorite server-side scripting language (PHP, PERL, ASP, etc) to search for the MP3s in a specific dir and then pass the results to flash via the new LoadVars class :).

Here is a PHP script that will read all the files in a specified directory and if they are an MP3 will out put a flash-formated string of text that can be loaded via the LoadVars class or getURL or the LoadVars function.



<?php
	   	//starting directory
    	$startDir = "/home/httpd/htdocs/";
		//count for flash array
		$count = 0;
    	//open directory
    	$openDir = opendir($startDir);
    	//loop while there are still things to be read in directory
    	while($path = readdir($openDir))
    	{
    		//gets the base name of file i.e instead of /home/music/blah.mp3 its blah.mp3
    		$file = basename($path);
    		//makes sure we dont we read the . and .. direcotry (current directory and parent directory)
    		if($file!="." && $file!="..")
    		{ 
    			//if its not a directory print out the stats (can be changed for your needs)
    			if(!is_dir($startDir."/".$file)){
					//Make sure file is MP3
					$file_ext = substr($file, strlen($file)-3, 3);
					if($file_ext == "MP3" or $file_ext == "mp3"){
						if($count != 0){ print "&"; }
						print "mp3Files[$count]=".urlencode("$file");
						$count++;
					}
    			} //end if
    		} //end if
    	} //end while
?>


That is what I usually do when I do MP3 playlists, hope this helps.

thanks i will give it a look :} :}