Hello!
I’m using the script below to slide pictures read from a XML file.
My project got 12 slideshowz like this one loading differents sets of pictures.
My question : I was wondering what I could change in every FLA the current location of the XML file to load in order to have only ONE .as script without any needs to duplicate and change a line in it every time.
You would save me.
Many thanks
As for now, this script is a document class.
public class A_Slideshow extends MovieClip
{
var xmlLoader:URLLoader;
var theXML:XML;
var photos:XMLList;
var photoLoader:Loader;
var photoArray:Array;
var fade:Tween;
var curr:Number;
var timer:Timer;
var timey:timeDisplay;
public function A_Slideshow():void
{
xmlLoader = new URLLoader();
** xmlLoader.load(new URLRequest("xml/A_PRODUITS.xml"));**
xmlLoader.addEventListener(Event.COMPLETE, getXML);
photoArray = new Array();
curr = 0;
timer = new Timer(5000);
timer.addEventListener(TimerEvent.TIMER, switchPhoto);
timey = new timeDisplay();
}
private function getXML(e:Event):void
{
theXML = new XML(e.target.data);
photos = new XMLList(theXML.photo);
for(var i:int=0;i<photos.length();i++)
{
photoArray.push(photos*.@url);
}
timer.start();
switchPhoto(null);
}
private function switchPhoto(e:TimerEvent):void
{
if(curr < photoArray.length)
{
photoLoader = new Loader();
photoLoader.load(new URLRequest(photoArray[curr]));
curr++;
photoLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, showProgress);
photoLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, removeTimey);
}
else
{
curr = 0;
switchPhoto(null);
photoLoader.unload();
}
}
private function removeTimey(e:Event):void
{
photoLoader.x= 0;
photoLoader.y= 0;
addChild(photoLoader);
fade = new Tween(photoLoader,"alpha",None.easeNone,0,1,2,true);
}
}
}