# XML slide show (wtih sync'd audio) setInterval

**URL:** <https://forum.kirupa.com/t/xml-slide-show-wtih-syncd-audio-setinterval/191610>\
**Category:** flash\
**Created:** [June 21, 2006, 7:44pm UTC](https://forum.kirupa.com/t/xml-slide-show-wtih-syncd-audio-setinterval/191610 "2006-06-21T19:44:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![timmcguckin](https://avatars.discourse-cdn.com/v4/letter/t/4491bb/32.png) [@timmcguckin](https://forum.kirupa.com/u/timmcguckin)\
**Post date:** [June 21, 2006, 7:44pm UTC](https://forum.kirupa.com/t/xml-slide-show-wtih-syncd-audio-setinterval/191610/1 "2006-06-21T19:44:35Z")

</div>

Briefly - I am creating a slideshow that dynamically loads the information (images, overlays, audio time code, and text) from an XML file. I am looping through the XML to create stacked “containers” that house the image, overlay and text. I want to fade out the uppermost image at specific timecodes set from the XML file attribute “timecode”.

The script loads the all the containers perfectly, but does not set the unique timer (setInterval) for each container movieclip. ANY HELP IS MUCH APPRECIATED 🙂

/\* Import MX.transitions & easing _/  
import mx.transitions._;  
import mx.transitions.easing._;  
/_-----------------------------------------------------------  
variable declarations  
-----------------------------------------------------------_/  
var slides\_xml:XML;  
var imageDepth:Number;  
var overlayDepth:Number;  
var textDepth:Number;  
/_-----------------------------------------------------------  
functions  
-----------------------------------------------------------_/  
function SlideShow(xmlFile:String) {  
slides\_xml = new XML();  
slides\_xml.ignoreWhite = true;  
//  
// Set the depths  
imageDepth = 3;  
overlayDepth = 4;  
textDepth = 5;  
//  
// verify the XML Load  
slides\_xml.onLoad = function(p\_success:Boolean):Void {  
if (p\_success) {  
trace(":: Stories XML Loaded ::");  
populateSlides();  
} else {  
trace(":: Stories XML Error ::");  
}  
};  
//  
// load the XML  
slides\_xml.load(xmlFile);  
}  
function populateSlides() {  
trace("::populateSlides()::");  
trace(slides\_xml.firstChild.attributes.audio);  
trace(slides\_xml.firstChild.attributes.title);  
//  
// Set Variables  
var timeCode:String;  
var container:String;  
var numOfPhotos:Number = slides\_xml.firstChild.childNodes.length;  
var i:Number;  
//  
// LOOP through the XML - Start at 1 instead of 0  
for (i=0; i\<numOfPhotos; i++) {  
//  
// Local variables to store the slide number  
container = “slide”+i+"\_mc";  
//  
// create the container movieclip  
this.createEmptyMovieClip(container, getNextHighestDepth());  
//  
// within “container” create movieclips for the image, overlay and text  
[container]createEmptyMovieClip(“image\_mc”, getNextHighestDepth());  
[container]createEmptyMovieClip(“overlay\_mc”, getNextHighestDepth());  
[container]createEmptyMovieClip(“text\_mc”, getNextHighestDepth());  
//  
// create the caption display textField within “text\_mc”  
[container]text\_mc.createTextField(“quoteText”, 7, 50, 100, 400, 20);  
[container]text\_mc.quoteText.wordWrap = true;  
[container]text\_mc.quoteText.multiline = true;  
[container]text\_mc.quoteText.autoSize = true;  
//  
// populate the movie clips & text field from the XML attributes variables  
[container]image\_mc.loadMovie(slides\_xml.firstChild.childNodes_.attributes.image);  
[container]overlay\_mc.loadMovie(slides\_xml.firstChild.childNodes\*.attributes.overlay);  
[container]text\_mc.quoteText.text = slides\_xml.firstChild.childNodes\*.attributes.quote;  
//  
// from the XML “timeCode” attribute, create a setInterval timer  
[container]timeCode = slides\_xml.firstChild.childNodes\*.attributes.timecode;  
[container]timer = setInterval(myCuePoint, (timeCode\*1000));  
trace(timeCode);  
}  
//  
// The function called from the setInterval [container]timer  
function myCuePoint() {  
clearInterval([container].timer);  
var fade:Object = new Tween([container], “\_alpha”, Strong.easeOut, 100, 0, 5, true);  
trace(container+" : "+timeCode);  
}  
}  
SlideShow(“data/slides.xml”);

--------------------THE XML--------------------

\<?xml version=“1.0” encoding=“UTF-8”?\>  
\<SlideShow audio=“audio/audio1.mp3” title=“Slide Show Test”\>  
\<slide image=“images/image4.jpg” overlay=“images/overlay4.png” timecode=“4.123” quote=“This text goes with the image 4 and audio.” /\>  
\<slide image=“images/image3.jpg” overlay=“images/overlay3.png” timecode=“3.123” quote=“This text goes with the image 3 and audio.” /\>  
\<slide image=“images/image2.jpg” overlay=“images/overlay2.png” timecode=“2.123” quote=“This text goes with the image 2 and audio.” /\>  
\<slide image=“images/image1.jpg” overlay=“images/overlay1.png” timecode=“1.123” quote=“This text goes with the image 1 and audio.” /\>  
\</SlideShow\>
