获取每个加载的图像
问题描述:
图像只加载到最后一个MC,如何使它加载到每个MC?获取每个加载的图像
private function imageHandler():void {
imageBox=new MovieClip();
imageBox.graphics.lineStyle(5, 0xFFFFFF);
imageBox.graphics.beginFill(0xFF0000);
imageBox.graphics.drawRect(0,0,150,225);
imageBox.graphics.endFill();
allImage.addChild(imageBox);
}
private function getPhoto():void {
for (i=0; i<myXMLList.length(); i++) {
placePhoto();
imageHandler();
imagesArray.push(imageBox);
imagesArray[i].x=20+(200*i);
}
addChild(allImage);
allImage.x=-(allImage.width+20);
allImage.y=-(allImage.height+50);
}
private function placePhoto():void {
loadedPic=myXMLList[i][email protected];
galleryLoader = new Loader();
galleryLoader.load(new URLRequest(loadedPic));
galleryLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,picLoaded);
}
private function picLoaded(event:Event):void {
var bmpD=event.target.content.bitmapData
for (j; j<myXMLList.length(); j++) {
bmp=new Bitmap(bmpD);
bmp.smoothing=true;
bmp.name="bmp"+j;
imagesArray[j].addChild(bmp);
}
}
答
它现在,但它表明
TypeError: Error #2007: Parameter child must be non-null.
at flash.display::DisplayObjectContainer/addChild()
at classes::section1/picLoaded()
在imagesArray [j]的.addChild(bmpArray [J]);
private function placePhoto():void {
loadedPic=myXMLList[i][email protected];
galleryLoader = new Loader();
galleryLoader.load(new URLRequest(loadedPic));
galleryLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,picLoaded);
}
private function picLoaded(event:Event):void {
var bmpD=new Bitmap(event.target.content.bitmapData);
bmpD.smoothing=true;
bmpArray.push(bmpD);
for (j; j<myXMLList.length(); j++) {
imagesArray[j].addChild(bmpArray[j]);
}
}
它有什么问题?
好吧,所以我意识到Event.COMPLETE函数后,循环将需要重新计算一遍,我把一个单独的循环在picLoaded函数。但是,我怎样才能将新的内容数据传入循环? – Hwang 2010-03-29 04:55:24