Here’s my code:
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);
}
The problem is trace(image) returns _level0.thumb_container.thumb_0.image_container which is the parent of image. I can’t work out why it isn’t returning the image I attached (The image does not appear in the SWF either).
Note: The image property in the people array is the linkage id exported for ActionScript.
Edit: If I put them in a MovieClip and load them they work fine, but there seem to be many people using attachMovie() with images
You can’t load bitmap using
MovieClip.attachMoviebecause 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.It returns the
imageand displays it as well.