Giving instance names to component buttons added through xml

Hey all.

I’m trying to make a xml website for school and cant seem to get one part to work.

I want to set it up so that each time a new entry is added into the xml file, such as <website filename = “websites/web1.html” label = “web1” /> it creates a new button, and that button pulls the text from that HTML.
Ive got as far as to have it so that as many entries there are, it makes that many buttons, but i cant seem to work out how to give each of these an instance name or something of the like so I can reference them to say what text they should be getting.

Heres the whole code so far, im not sure exactly what part anyone would want to see to help, so ill add it all :stuck_out_tongue:

import fl.controls.UIScrollBar;
import fl.controls.Button;

var websiteXML:XML;
var websiteXMLList:XMLList;
var xmlLoader:URLLoader = new URLLoader;
var pageNumber:Number = 0; 
var HTMLLoader:URLLoader = new URLLoader;
var i:Number = 0;
var n:Number = 0;

xmlLoader.load(new URLRequest ("websites.xml"));
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);

function xmlLoaded(event:Event):void {
    websiteXML = XML(event.target.data);
    websiteXMLList = websiteXML.children();
    createButtons();
}

function createButtons():void {
    for (i = 0; i < websiteXMLList.length(); i++) {
        var aButton:Button = new Button();
        addChild(aButton);
        aButton.label = (websiteXMLList*.attribute("label"));
        aButton.toggle =  true; 
        aButton.addEventListener(MouseEvent.CLICK, clickHandler);
        aButton.width = 60;
        aButton.x = n + web1_txt.y + 50;
        aButton.y = 210
        n = n + 65
        }

}
    function clickHandler(event:MouseEvent):void {
    loadhtml();
    }


//----------------------------------------//
function loadhtml():void {
    HTMLLoader.load(new URLRequest(websiteXMLList[pageNumber].attribute("filename")))
    HTMLLoader.addEventListener(Event.COMPLETE, htmlLoaded)
}
function htmlLoaded(event:Event):void {
    web1_txt.htmlText = event.target.data;
    
    var vScrollBar:UIScrollBar = new UIScrollBar();
    vScrollBar.scrollTarget = web1_txt;
    vScrollBar.height = web1_txt.height;
    vScrollBar.move(web1_txt.x + web1_txt.width, web1_txt.y);
    addChild(vScrollBar);

}

Thanks heaps!