0

I have the following code which traverses an XMLList of nodes:

function determineFacilities(facilities:XMLList, item:MovieClip) {
    for(var i:int = 0; i > facilities.length(); i++) {
        if(Boolean(facilities[i].text()) == true) {
            var imgName:String = facilities[i].nodeName + ".png";
            // need to load and position image here
        }
    }
}

If the current node's text is true, then I need to load an Image with the same name as the node (plus the extension) and position it.

How would I go about doing this?

Thanks.

Nick
  • 1,269
  • 5
  • 31
  • 45

1 Answers1

0

Try this:

var bitmap:Bitmap;

var loader:Loader = new Loader();
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
    loader.load(new URLRequest(imgName));

function onComplete (event:Event):void
{
    bitmap = Bitmap(LoaderInfo(event.target).content)
    bitmap.x = yourX;
    bitmap.y = yourY;
    addChild(bitmap)
}

extracted from: How do you load a bitmap file into a BitmapData object?

Community
  • 1
  • 1
Mc-
  • 3,968
  • 10
  • 38
  • 61