? geting the number of jpg's as a variable from a folder


how can i give a value to my variable depending on how many .jpg’s i have
in my pictures folder.
lets say I have 53 jpg’s in the pictures folder and I need myvariable=53,
and if i put the 54th in, flash should update this value on _root.onLoad or on
what ever.

I don’t believe flash can do this alone, I normally use a php script to list directory contents:

  	// Open directory
  	$myDirectory = opendir("path	o\directory");
  	// get each entry
  	while($entryName = readdir($myDirectory))
  	$dirArray[] = $entryName;
  	// close directory
  	//  count elements in array
  	$indexCount	= (count($dirArray));
  	// return the amount of files in the directory to flash with :
      print "&myVariable=" . urlencode($indexCount+1);

Save that as listdirectory.php and use the following code in flash:

  dirCount = new LoadVars();
  dirCount.onLoad = function(success) {
  	if (success) {
  		_root.myVariable = this.myVariable;
  	} else {
  		trace("directory listing error");

Then just call the function everytime you want to flash to check/update/refresh the variable, by using this:


Hope this helps… off the top of my head, but it should work okay.

It works perfect.