Type coercion error
This is from another thread that I marked fixed but I still have an issue, so I thought I would start a new post.
I'm loading images from xml into an array of movieClips. I'm almost there thanks to a bunch of your responses.
I'm getting a type coercion error that I traced down to this line:
mainClipArray[counter].addChild(e.target);
It doesn't seem to like the e.target. Anyone see the error?
CODE:
var myXML:XML;
var xmlLoader:URLLoader = new URLLoader();
var mainClipArray:Array = [];
var counter:int = 0;
xmlLoader.load(new URLRequest("portfolio.xml"));
xmlLoader.addEventListener(Event.COMPLETE, completeXMLLoad);
function completeXMLLoad(e:Event):void{
myXML = XML(e.target.data);
var len:int = myXML.portfolio.unit.length();
loadMainImage();
}
function loadMainImage(){
var myLoader:Loader = new Loader();
var smallfilename = myXML.portfolio.unit[counter].small.filename;
myLoader.load(new URLRequest(smallfilename));
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeClipLoad);
}
function completeClipLoad(e:Event):void{
mainClipArray[counter] = new pane();
mainClipArray[counter].addChild(e.target);
addChild(mainClipArray[counter]);
mainClipArray[counter].x = counter * 15;
mainClipArray[counter].y = 320 - mainClipArray[counter].height;
counter ++;
if(counter < myXML.portfolio.unit.length()){
loadMainImage();
} else {
layoutImages();
}
}
function layoutImages(){
}