Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pictures from folder

Status
Not open for further replies.

Dinobot2

Technical User
Aug 9, 2005
75
US
Does anyone know a way to have macromedia call all pictures from a particular folder to have them play.

OK, I made a page with a title. underneath the title I want different pictures to fade in and out. I imported the pictures and when I play it, it works.

now other people wants to add pictures and I figured if I could have flash play those pictures from a particular folder without me having to import it from a ".fla" file then resave it as a ".swf", that would be better.

Ideas?
 
not difficult but you will need a server side script (php ?) to read the folder and return a list of files found to flash

if you want a php script to do this then just ask

 
I am currently using an XML file. I find this extremely easy to call any picture from anywhere.

It is easy to edit as well, either manually or by simply writing a little php interface (or java or whatever you want to use to write to the xml file)

A bit of sample code for calling the file and taking the values from the child objects. Note that the XML file is called images.xml and that I put in a var to determine the path of the SWF just in case the SWF and HTML file calling it are in different dirs.

Code:
function loadXML(loaded) 
{ 
	if (loaded) 
	{ 
		xmlNode = this.firstChild; 
		image = []; 
		description = []; 
		thumbnails = []; 
		total = xmlNode.childNodes.length; 
		for (i=0; i<total; i++) 
		{ 
			image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue; 
			description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue; 
			thumbnails[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue; 
			thumbnails_fn(i); 
		}
		firstImage(); 
	} 
	else 
	{ 
		content = "file not loaded!"; 
	} 
} 

var path:String = this._url;
path = path.substring(0, path.lastIndexOf("/")+1);

xmlData = new XML(); 
xmlData.ignoreWhite = true; 
xmlData.onLoad = loadXML; 
xmlData.load(path+"images.xml");

I'll be happy to explain a bit further if required


JR (IT = Logic (except for a well known OS where it equals luck) -> Back to the Basics!
 
That works fine if you know the name and location of the jpgs but if its a situation where the client will add/remove jpgs from a folder on a regular basis then you need a server side script to determine at run time the contents of the folder.
 
Good point. If the client adds/removes files from a folder on a regular basis you must make sure that the xml file reflects this.

The XML file is read on run time, so if it changes FLASH should read the latest information from it (which it should do using the above script) and reflect any changes.

I say 'FLASH should', because I know FLASH not to do the things you tell it to and it loves to cache stuff and never look at anything else ever again. Perhaps there is an option to tell it not to cache itself?

Anyway, when your customer uploads or removes files you can simply use a scripting language or programming language to update the XML file and you are done. Easy not?

JR (IT = Logic (except for a well known OS where it equals luck) -> Back to the Basics!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top