External swf loader

So I have a swf file that loads external swfs from buttons that get called to the stage via AS3.

http://at.bc.edu/panoramas/main.swf

Right now, it loads the swf’s from one button that is called to the stage. And numbered accordingly in AS3.

Basically what I want to do, instead, is create five different buttons that load the external swf’s the same way.

In the example it keeps calling the same button for all five links. But I would like specific custom buttons for each.

So what I did was, I kept the 5 numbered buttons from the example in the file, and I duplicated the ‘btn’ movieclip that is called 5 times. And inserted different images into each one of them that correspond to the external swf I am loading.

**The thing I can’t figure out is since it’s calling ‘btn’ 5 times, I can’t figure out how to replace the numbered buttons with the 5 different buttons I need to call that I created.
**
Can you tell me how to put this in the code?

Also, if you can tell me how to put it in the code, can you be as detailed as possible? AS confuses me to no end, never mind AS3.

Here is the only code I use:


// creates the loaders and functions, automatically loads first swf(1.swf) \\
var loader:Loader = new Loader();
var loaderAll:Loader = new Loader();
var percen:Number = 100;
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, preload);
loaderAll.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, preload);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaded);
loaderAll.contentLoaderInfo.addEventListener(Event.COMPLETE, loadedAll);
loader.load(new URLRequest("http://at.bc.edu/panoramas/rowingholder.swf"));


function preload(e:ProgressEvent):void
{
    percent.text = String(Math.round(e.bytesLoaded / e.bytesTotal * percen) + "%");
    percent.alpha = Math.random();
    
    if(percen <= 100)// disables navigation buttons until swf is loaded
    {
        buttonHolder.mouseChildren = false;
    }
}

function loaded(e:Event):void
{
    external.visible = false;
    removeChild(percent);
    addChild(loader);
    loader.x = external.x + 4;
    loader.y = external.y + 4;
    buttonHolder.mouseChildren = true;
}


function loadedAll(e:Event):void
{
    buttonHolder.mouseChildren = true;
    external.visible = false;
    removeChild(percent);
}
// creates the loaders and functions, automatically loads first swf(1.swf) \\




// creates navigation buttons
// 10 button nodes = 10 nav buttons that each one loads your exernal swf file
var xml:XML;
xml =
<nav>
<button labl="1" link="http://at.bc.edu/panoramas/rowingholder.swf"/> // button labl = text for navigation button
<button labl="2" link="http://at.bc.edu/panoramas/2.swf"/> // link = external swf link
<button labl="3" link="http://at.bc.edu/panoramas/3.swf"/>
<button labl="4" link="http://at.bc.edu/panoramas/4.swf"/>
<button labl="5" link="http://at.bc.edu/panoramas/5.swf"/>
</nav>;

// dynamic variable that captures the id number of the button clicked
var targetID:int;


// movieclip container to hold the buttons
var buttonHolder:MovieClip = new MovieClip();

// array holds references to the buttons in a list
// the targetID variable coresponds to the index of the button clicked
var buttonArray:Array = new Array();



// call the nav constructor and pass in the number of button nodes, and the desired padding between the buttons
buildNav(xml..button.length(), 1);

function buildNav(n:int, padding:int):void
{
    // create 1 button for each button node (n) in the xml list
    for (var i:int = 0; i < n; i++)
    {
        
        var b:Btn = new Btn();// library symbol from which the buttons are created.
        b.x = (b.width + padding) * i;// create padding between buttons
        b.y = 0;// all buttons at x:0 
        b.id = i;// identify the button by this integer
        b.buttonMode = true;// hand cursor
        b.mouseChildren = false;// stop mouse events 
        b.navTxt.text = String(xml..button*.@labl);// label the button
            
        b.addEventListener(MouseEvent.ROLL_OVER, onOver);
        b.addEventListener(MouseEvent.ROLL_OUT, onOut);
        b.addEventListener(MouseEvent.CLICK, onClick);
        
        buttonArray.push(b);
        buttonHolder.addChild(b);
    }
    
    buttonHolder.x = navBg.width / 2 + 6; // nav buttons x position
    buttonHolder.y = navBg.y + 6; // nav buttons y position
    addChild(buttonHolder);
}



// Adds glow filter on navigations buttons, delete if you don't need it\\
var glowOver:GlowFilter = new GlowFilter(0xFF0000,0.5, 2, 2, 10, 1,true, false)
var glow:GlowFilter = new GlowFilter(0xFFFFFF,0.5, 2, 2, 10, 1,true, false);
// Adds glow filter on navigations buttons, delete if you don't need it\\

// enters the button symbol and plays the animation
// adds color on button text
function onOver(e:MouseEvent):void
{
    e.target.gotoAndPlay("over");
    e.target.navTxt.textColor = 0xFFFFFF;
    e.target.filters = [glowOver];
}


function onOut(e:MouseEvent):void
{
    e.currentTarget.gotoAndPlay("out");
    e.target.navTxt.textColor = 0x666666;
    e.target.filters = undefined;
}

function onClick(e:MouseEvent):void
{
    // targetID is assigned the id number from the currentTarget ( the button that was clicked )
    targetID = e.currentTarget.id;
     loader.unload();
    loaderAll.load(new URLRequest(xml..button[targetID].@link));
    addChild(loaderAll);
    addChild(percent);
    percent.text = String(null);
    loaderAll.x = loader.x;
    loaderAll.y = loader.y;
    external.visible = true;
    e.target.filters = [glow];
        if(targetID >= 0) // stops sound when a different button is clicked
            {
                SoundMixer.stopAll();
            }
}