获取每个加载的图像

发布于 2024-08-26 23:19:47 字数 1167 浏览 0 评论 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].@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);
        }
}

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

子栖 2024-09-02 23:19:47

它现在可以工作,但它显示

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

有什么问题吗?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文