Passing the time from the XML to the application is really not that hard, we can set an attribute in our root XML tag and grab it to set our target time. We could also define a new tag in our XML to hold the time value but let’s stick with an attribute here. Here is our modified XML slide show root tag:

<SLIDE_SHOW DisplayingTime='4'>

Let’s go back in our completeHandler function and grab this value:

display_time = Number(xml_pictures.attribute("DisplayingTime")) || 5;

//set our time from the attribute or set it

//to 5 if the value is not valid

That was hard I know. Let’s assume that the first picture is required to load fine (we could handle that too but I leave it up to you to implement if you want) so now let’s handle any following picture loading error by adding an IOError event to our loader:


and our new save_slide_show function just saves the day:

private function save_slide_show(e:IOErrorEvent):void{

picture_loader = new Loader();








That’s it, any wrong paths will just be skipped, now remember you might not want that since if you have a wrong path the slide show will still be working fine and you might never realize that you are missing a picture. Also you might want to handle the case when it’s time to display a picture but the picture is not fully loaded yet. So if you want to display any kind of preloader when that happens you’ll do it here:

private function check_target_time(e:TimerEvent):void{


display_timer.removeEventListener(TimerEvent.TIMER, check_target_time);

isDisplayTime = true;

//check this boolean to true so we know it's time to display the picture

//if the picture is ready then display it



//start your preloader here




then you remove your preloader here:

private function picture_ready(e:Event){

isPictureReady = true;

//the picture is loaded so set the boolean to true


//if this boolean is true then that means the timer

//ran out so display the picture


//remove your preloader here



Now let’s wrap all that up into a class. We’ll call it TimeManager class and beside the fact that it will keep our code organized, it will also make it simpler to add more functionality later on. So you’ll find most of the code you saw so far in this new class the only differences being that this class dispatches an event that we use to add new pictures (that we get from this class) to the display list in our document class. That’s it for this article, next time we will resize all these pictures (and the swf itself!).