Google Answers Logo
View Question
Q: Flash MX2004Pro xml/jpg slideshow that plays a loop of images using no buttons ( Answered 5 out of 5 stars,   1 Comment )
Subject: Flash MX2004Pro xml/jpg slideshow that plays a loop of images using no buttons
Category: Computers
Asked by: dwilder20-ga
List Price: $25.00
Posted: 13 Sep 2004 07:40 PDT
Expires: 13 Oct 2004 07:40 PDT
Question ID: 400506
please explain how to code FlashMXPro2004 actionscript to access an
XML file and an image array to run a slideshow/presentation that
simply starts playing when the user accesses the page---without using
There are 14 images and they just loop. I started with the xml/JPG
Slideshow code available on Macromedia's website but it's based on a
"next/Previous" --I assume there is an obvious answer to this that I'm
just missing.

Thanks for your help

Request for Question Clarification by andyt-ga on 14 Sep 2004 17:36 PDT
Hi dwilder20-ga,
I might be able to help with this, but to do it, there needs to be a
time delay before moving onto the next image.  Is it ok if this time
delay is hardcoded into the flash file, or do you want it to be
defined individually for each image in the xml file?


Request for Question Clarification by andyt-ga on 14 Sep 2004 18:00 PDT
Hello again,
Also I will need to know if you want the slideshow to loop
indefinitely, or if it should stop once all of the pictures have been
shown once.


Clarification of Question by dwilder20-ga on 19 Sep 2004 16:38 PDT
What I need is a non event driven navigation--I tried onLoad but it
needs to access the xml---perhaps some sort of timer (getTimer?) in
the Flash would be nice--so it could be adjusted. The irony in all of
this is how easy this would be to hard code in flash--which is how
I've always done it --trying to do it in code with external files and
xml has been a trial.

I would like the option to loop or stop after x-series.

David Wilder
Subject: Re: Flash MX2004Pro xml/jpg slideshow that plays a loop of images using no buttons
Answered By: andyt-ga on 20 Sep 2004 17:36 PDT
Rated:5 out of 5 stars
Hi David,
Thanks for allowing me the opportunity to answer your question,
programming actionscript is always a pleasure.  I've attached below
the full code for the frame 1 actions, modified from the Macromedia
exmaple that you mentioned in your question.  For reference this
tutorial is available at

This program will advance a slideshow using a definable time delay
(variable = delayTime) and a definable number of loops (variable =
loopAmount).  The solution does not include the event driven functions
that control the next and back buttons, so I've removed these
functions.  Instead, the flash builtin function setInterval calls the
advancePicture function every x milliseconds, defined by delayTime.

I've posted the full project at  If you
have any questions about the code, or require any additional
assistance, don't hesitate to request a clarification.


//flash actionscript code from frame 1

delayTime=1000; //delay between each picture advancing in milliseconds
loopAmount= 3; //how many times the pictures will loop, 0 for infinite
//initializes the counter to 1.  everytime all the pictures 
//have been shown, counter increments

function advancePictures()  {                //  a function to advance the pictures
     //trace("count: "+count); 
     //trace("loop amount: "+loopAmount); 

			nextSlideNode = currentSlideNode.nextSibling;
				if (nextSlideNode == null) {
					//reset slides to beginning and increment the counter
					//if loopAmount is 0 (infinite) or if loopAmount is less then the counter
					if(loopAmount==0 || counter<loopAmount)	{
						firstSlideNode = rootNode.firstChild;
						currentSlideNode = firstSlideNode;
						currentIndex = 1;
					//if count is more then loopAmount, then stop looping
					else	{
				else {
					currentSlideNode = nextSlideNode;


slides_xml = new XML();
slides_xml.onLoad = startSlideShow;
slides_xml.ignoreWhite = true;

// Show the first slide and intialize variables
function startSlideShow(success) {
	if (success == true) {
		rootNode = slides_xml.firstChild;
		totalSlides = rootNode.childNodes.length;
		firstSlideNode = rootNode.firstChild;
		currentSlideNode = firstSlideNode;
		currentIndex = 1;

		//calls the advancePictures function every 'delayTime' in milliseconds
		myTimer = setInterval(advancePictures,  delayTime); // calls the
function after 1 second


// Updates the current slide with new image and text 
function updateSlide(newSlideNode) {
	imagePath = newSlideNode.attributes.jpegURL;
	slideText = newSlideNode.firstChild.nodeValue;
	loadMovie(imagePath, targetClip);

Clarification of Answer by andyt-ga on 21 Sep 2004 16:30 PDT
Glad it worked out for you, I've been working on the fade thing for
awhile, and can't seem to figure it out, and will probably be busy for
the next couple days.  I'd advise posting it as another question not
specifically directed at me; and maybe someone else will have better
luck.  You can direct them to the zip file I posted if you like. 
Also, if I do figure it out, I'll answer it.
dwilder20-ga rated this answer:5 out of 5 stars
This looks great!!
For an additional $25 would you add a 100 to zero fade from the
current image to the next image---

Subject: Re: Flash MX2004Pro xml/jpg slideshow that plays a loop of images using no buttons
From: earganic-ga on 22 Dec 2004 19:14 PST
This was exactly what i wanted help with. I love google. By any chance
was that 100-0 fade ever incorporated? I like to add that as well.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  

Google Home - Answers FAQ - Terms of Service - Privacy Policy