2010-03-27 1 views
0

이미지는 마지막 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); 
     } 
} 
+0

좋아요, 그래서 Event.COMPLETE 함수 후에 루프를 다시 계산해야 할 것입니다. picLoaded 함수에 개별 루프를 넣습니다. 그러나 새로운 콘텐츠 데이터를 루프에 어떻게 전달할 수 있습니까? – Hwang

답변

0

이제 작동하지만

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]); 
     } 
    } 

무엇이 잘못 되었나요?