Load SWF files through XML sequentially in Same Target

As with many endeavors in Flash (and most programming environments),
there are several possible ways to accomplish your goal. Here’s one
approach with two steps:
**
Step1:**


// In frame 1 of the main timeline ...
var banner:XML =  new XML();
var videos:Array;
var currentVideo:Number =  0;

banner.ignoreWhite =  true;
banner.load("banner.xml");

banner.onLoad =  function(success:Boolean):Void {
if (success) {
videos =  this.firstChild.childNodes;
loadMovie(videos[currentVideo].attributes.url,  target_mc);
}
};

function loadNextVideo():Void {
currentVideo++;
if (currentVideo < videos.length) {
loadMovie(videos[currentVideo].attributes.url, my_mc);
}
else {
    currentVideo=0;
    loadMovie(videos[currentVideo].attributes.url, my_mc);
    }
}

The above lines would replace what you currently have. Note that in
this case, the videos array is declared outside of any function, which
scopes the variable to the main timeline (this means it is accessible to
code outside of the function – in your previous version, the videos array
was only accessible inside your onLoad event handler function).

Loading happens as before, but for sake of completeness, I’ve added the
strong typing (:Boolean and :Void) that weren’t there before. They’re not
strictly needed, but it’s a good practice to get into the habit. Notice
that the for() loop is now gone. In its place, the loadMovie() call simply
loads the first video in the array – first, because the value of
currentVideo is zero.

Finally, a custom function, loadNextVideo(), updates the value of
currentVideo by one (++), then checks if that value is still within the
range of the video array’s length. If so, it calls the same loadMovie()
function as before. This time, the value of currentVideo is 1, so the
second video is loaded. Next time, that value will be 2, so the third video
will be loaded. After that, the value will be 3 – and, assuming there are
only three videos, the value of currentVideo will no longer be less than
videos.length, so the loadMovie() function won’t be called again.

Step2:
The only “trick,” now, is to call this loadNextVideo() function at the
right time. This can be accomplished by putting a bit of keyframe code into
the last frame of each SWF file that gets loaded:


// In the last keyframe of  each external SWF ...
this._parent.loadNextVideo();

Assuming target_mc is an immediate child of the main timeline, the
expression, this.parent will point to the main timeline from the inside of
each external SWF. With a proper reference to the main timeline, the
loadNextVideo() function can be executed.

**An XML Structure:
**


<?xml version="1.0" encoding="ISO-8859-1"?>

<videos>
    <video url="c.swf" />
    <video url="d.swf" />
    <video url="e.swf" />
</videos>