I am trying to use a list box to show a list of items, and load different images as referenced in the XML when the user changes the selection in the list box. I have the list box created, and have written out a text area to make sure the data is coming through OK when selection changes, but when I pass the image URL to the loader, it doesn’t work, but no errors are thrown. I get a good path to the image from the bInput variable below, but when I add that to the loader1 loader variable, I just get [object Loader] from the trace.
Can someone tell me what I am missing here?
Thanks.
import fl.video.*;
import flash.events.*;
import flash.display.MovieClip;
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onLoaded);
lb.addEventListener(Event.CHANGE, itemChange);
function itemChange(e:Event):void
{
ta.text = lb.selectedItem.data;
imageChange(lb.selectedItem.data);
}
function imageChange(bInput:XML):void {
trace (bInput);
var loader1:Loader = new Loader();
loader1.load(new URLRequest( bInput ) );
trace (loader1);
var bmd1:BitmapData = new BitmapData(570,427);
bmd1.draw(loader1);
var bm1:Bitmap = new Bitmap(bmd1);
bm1.x = 372;
bm1.y = 23;
addChild(bm1);
}
var xml:XML;
var movie:String;
function onLoaded(e:Event):void
{
xml = new XML(e.target.data);
var il:XMLList = xml.slidedeck.slide;
for(var i:uint=0; i<il.length(); i++)
{
lb.addItem({data:il.image.text()*,
label:il.title.text()*});
}
}
loader.load(new URLRequest("testdata_full.xml"));