0

これが私のコードです:

var people:Array = [
    {
        image: "1.jpg",
        labels: 
            [
                "Valium dependant",
                "Anger issues",
                "Single parent"
            ]
    },{
        image: "2.jpg",
        labels: 
            [
                "Alcoholic",
                "Bipolar disorder",
                "Smokes cannabis"
            ]
    },{
        image: "3.jpg",
        labels: 
            [
                "Glue sniffer",
                "Suffers from anxiety",
                "Has terminal cancer"
            ]       
    },{
        image: "4.jpg",
        labels: 
            [
                "Ecstasy user",
                "Binge drinker",
                "Depressed"
            ]       
    },{
        image: "5.jpg",
        labels: 
            [
                "Homeless",
                "Heroin user",
                "Smokes"
            ]       
    },{
        image: "6.jpg",
        labels: 
            [
                "Uses poppers",
                "LSD user",
                "Cocaine user"
            ]       
    }
];

var thumb_container:MovieClip = this.thumb_container;
for (index in people) {
    var thumb:MovieClip = thumb_container.attachMovie("Thumbnail", "thumb_" + index, thumb_container.getNextHighestDepth());
    var image_container:MovieClip = thumb.image_container;
    var image:MovieClip = image_container.attachMovie(people[index].image, "image_" + index, image_container.getNextHighestDepth());
    trace(image);
}

問題は、の親であるtrace(image)returnsです。添付した画像が返されない理由がわかりません(画像はSWFにも表示されません)。_level0.thumb_container.thumb_0.image_containerimage

注:配列のimageプロパティは、peopleActionScript用にエクスポートされたリンケージIDです。

編集:それらをMovieClipに入れてロードすると、正常に機能しますがattachMovie()、画像を使用している人は多いようです

4

1 に答える 1

0

You can't load bitmap using MovieClip.attachMovie because it can't recognize the bitmap files. It's purpose is to load movieclips only and not other types. So you have to make bitmap data first then attach this bitmap data to the movieclip.

var thumb_container:MovieClip = this.thumb_container;
for (index in people) {
    var thumb:MovieClip = thumb_container.attachMovie("Thumbnail", "thumb_" + index, thumb_container.getNextHighestDepth());
    var image_container:MovieClip = thumb.image_container;
    var bmp:BitmapData = BitmapData.loadBitmap(people[index].image);
    var image:MovieClip = image_container.attachBitmap(bmp, image_container.getNextHighestDepth());
    trace(image);
}

It returns the image and displays it as well.

于 2012-10-03T10:10:08.523 に答える