Experts, please help.
I am currently using the XML Slideshow Banner script from
http://webdevils.com/examples/xml_b...how_banner.html and quite like the display it produces. Thing is I am now using another script (home.swf) to firstly process the xml and if successful include the XML_Slideshow_Banner.swf file, sending the xml stuff to it. This is the code from home.swf:
// Create a new XML object
show.addListener(this);
var my_xml = new XML();
my_xml.ignoreWhite = true;
my_xml.load( "/xml/slideshow.xml" );
// Set up onLoad function
my_xml.onLoad = newSlides;
function newSlides( success ) {
if ( success ) {
// Make an array from the xml file
for ( var i = 0; i < this.childNodes.length; i ++ ) {
if ( this.childNodes[i].nodeNam
e == "slideshow" ) {
// Get the wait attribute
wait = Number( this.childNodes[i].attribu
tes.wait );
// get all of the nodes inside of slideshow put them in image_xml
var image_xml = this.childNodes[i].childNo
des;
// make a new empty array named image_array
image_array = [];
// Loop through all of the nodes inside image_xml
for( var j = 0; j < image_xml.length; j ++ ) {
// Add a new empty array to the end of image_array
image_array.push( [] );
// Add path as a named element to the array we added above, give it a value from the url attribute in the xml file
image_array[ image_array.length - 1 ][ "path" ] = image_xml[j].attributes.ur
l;
// Add desc as a named element to the array we added above, give it the value of the text node
image_array[ image_array.length - 1 ][ "desc" ] = image_xml[j].firstChild.no
deValue;
}
}
}
//delete mc_slidecontainer;
mc_slidecontainer._x = 5;
mc_slidecontainer._y = 5;
loadMovie("/XML_Slideshow_
banner.swf
?" + (new Date()).getTime(), mc_slidecontainer);
gotoAndPlay("view");
} else {
trace('problem');
}
};
stop();
Home.swf is processing the above correctly and is loading XML_Slideshow_banner.swf but the problem is it doesn't seem to be sending the xml across. In XML_Slideshow_banner.swf I have the following code:
show.addListener(this);
// Create a new XML object
// Hide the progress bar when we begin
progressbar_mc._visible = 0;
// Start Slide show function
start_slideshow = function() {
count = 0; // Set count to 0, we'll use this to set the depth and instance names for the loaded MCs
image_index = -1; // set image_index to 0, we'll use this to keep track which image from the image_array we are currently displaying.
next_image(); // Call this function each time we want to show the next image from the array
setInterval( next_image, wait * 1000 ); // This will call the function next_image every 10 seconds.
};
// This function loads a new image by attaching a new MC to the stage and loading an image from the image_array
next_image = function() {
count ++; // Advance count by 1
image_index ++; // Advance image_index by 1, so next time around we'll get the next image.
if ( image_index >= image_array.length ) { // Here we should check to see if we have advanced past the last image in the array
image_index = 0; // If so, set image_index back 0 and we start over from the beginning again.
}
slideshow_mc.createEmptyMo
vieClip( "image_" + count, count ); // Create a new clip to load the new image into
slideshow_mc[ "image_" + count ].loadMovie( image_array[ image_index ].path ); // load a jpg from the image array
slideshow_mc[ "image_" + count ]._alpha = 0; // Hid this clip by setting it's alpha to 0, we'll animate the alpha later to show it after it loads.
show_loader( slideshow_mc[ "image_" + count ] ); // Show the progress bar, this function needs to know which clip to monitor as it loads so we pass the name of the clip as a paramter.
hide_display(); // Hide the display_mc, this shows the text.
};
next_image_ready = function() { // When our image loads it will call this function
slideshow_mc[ "image_" + count ].onEnterFrame = function() { // Assign the newest MC a function to animate it's alpha property
this._alpha += 10; // Each fram add 10 to the alpha property, set the speed of the animation here
if ( this._alpha >= 100 ) { // if alpha is 100 or greater we are done with the animation
image_done(); // Call image_done()
this.onEnterFrame = null;// Delete this function
};
};
};
image_done = function() { // The cycle is complete the new image has finished loading
slideshow_mc[ "image_" + ( count - 1 ) ].removeMovieClip(); // Remove the last image loaded, it should be hidden behind the most recent image loaded.
};
show_loader = function( watch_target ) { // Call this to show the progress bar, pass the MC to watch.
progressbar_mc._visible = 1; // Show the progressbar_mc
progressbar_mc.bar_mc._xsc
ale = 0; // Set the bar_mc, inside of progressbar_mc, _xscale to 0.
progressbar_mc.load_target
= watch_target; // Save the MC to watch in a variable
progressbar_mc.onEnterFram
e = function() { // This enterFrame function will monitor the loading process every frame.
var b = this.load_target.getBytesL
oaded(); // get bytes loaded
var t = this.load_target.getBytesT
otal(); // get bytes total
if ( t > 100 ) { // Wait til total shows a value to check for error
this.bar_mc._xscale = ( b / t ) * 100; // Set the _xscale of the bar based on % of bytes loaded.
if ( b == t ) { // when bytes loaded equals total bytes we are finished loading.
next_image_ready(); // This is image is ready to show now
show_display( image_array[ image_index ].desc );
this._visible = 0; // Hide the progress bar
this.onEnterFrame = null; // delete this enterFrame function
}
}
};
};
// As an experiment I called the show_loader function here and passed the xml object
// When the movie opens the loader shows and monitors the loading of the xml file.
show_loader( my_xml );
show_display = function( theText ) {
_parent.mc_captions.myCapt
ion.text = theText;
_parent.mc_captions.onEnte
rFrame = function() {
this._alpha += 10;
if ( this._alpha >= 100 ) {
this.onEnterFrame = null;
}
};
};
hide_display = function() {
_parent.mc_captions.onEnte
rFrame = function() {
this._alpha -= 10;
if ( this._alpha <= 0 ) {
this.onEnterFrame = null;
}
};
};
As you can see, I have removed function newSlides( success ). But it's not working.
I really need to be able to parse different xml files to XML_Slideshow_banner.swf as I have developed a content management system which will be used to edit the xml and depending on which section you are in depends on which xml file is being used. Please could someone help me. I'm at my wits end.
BTW, if I process the first function in home.swf which then pulls the XML_Slideshow_banner.swf (which also contains the same function and call to the xml file) it works. It's when I want to push the xml across that it seems to break.
Thank you very much for any help that can be provided.
Mark