开发者

Getting each loaded image

开发者 https://www.devze.com 2022-12-24 03:15 出处:网络
The images only loads into the last MC, how to make it load into each MC? private function imageHandler():void {

The images only loads into the last MC, how to make it load into each 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 functio开发者_如何学Cn 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].@PIC;
    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);
        }
}


It works now, but it shows

TypeError: Error #2007: Parameter child must be non-null.
    at flash.display::DisplayObjectContainer/addChild()
    at classes::section1/picLoaded()

at imagesArray[j].addChild(bmpArray[j]);

private function placePhoto():void {

        loadedPic=myXMLList[i].@PIC;

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

what's wrong with it?

0

精彩评论

暂无评论...
验证码 换一张
取 消