Trouble getting variables from an external image loader (XML) Please Help!

Hi guys,

I am trying to do everything as OOP as possible there for I am using an external class which loads images from an XML page.

This works perfectly and loads all images however I would like some of these images to be buttons and this is where I get stuck.

I have two files one index.as which calls LoadImageXML.as here is the code in the index.as…

var xmlFile = “XML/”;
var images = new LoadImageXML(xmlFile);
addChild(images);

…and here is the code in the LoadImageXML.as…

public function LoadImageXML(xmlFile:String)
{
var xmlLoader:URLLoader = new URLLoader();

        var xml:XML;
        var xmlList:XMLList;
        xmlLoader.load(new URLRequest(xmlFile+"AllImages.xml"));

        xmlLoader.addEventListener(Event.COMPLETE, onComplete);
        
        function onComplete(event:Event):void 
        {
            xml = XML(event.target.data);
            xmlList = xml.children();
            var ammount:int = xmlList.length();
            
            for (var i:uint; i < ammount; i++)
            {
                var imageLoader = new Loader();
                imageLoader.load(new URLRequest(xmlList*.attribute("thumb")));
                imageLoader.name = xmlList*.attribute("name");
                var imageButton = xmlList*.attribute("button");
                var xpos = xmlList*.attribute("xposition");
                var ypos = xmlList*.attribute("yposition");
                addChild(imageLoader);
                imageLoader.x = xpos;
                imageLoader.y = ypos;
                trace(imageLoader.name);
            }
        }

now if I thought I would get call my image names in the index file and then say if imagename = [button] then use a rollover class for instance. However when I try to call my imageLoader.name in index.as I get “undefined”.

Any ideas on how I can pull the variables from the external LoadImageXML class?

Or better yet, any ideas if I’m barking up the wrong tree with this being OOP? I want to reuse this code for the whole project if I can.

Thanks!!

Joe.