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>