這裏是我的代碼:的attachMovie()不工作
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)
回報_level0.thumb_container.thumb_0.image_container
這是image
父。我無法弄清楚爲什麼它沒有返回我附加的圖像(圖像沒有出現在SWF中)。
注意:people
數組中的image
屬性是爲ActionScript導出的鏈接ID。
編輯:如果我把它們放在一個影片剪輯並加載它們,他們工作得很好,但似乎有很多人使用attachMovie()
與圖像
數組'people'中的'image'屬性在**庫**或** url **中爲外部資源保存**鏈接ID **嗎? – Moorthy
@Moorthy它擁有庫中圖像的鏈接ID –
你的代碼對我有用(它會記錄圖像並將其顯示在圖像容器中)。但是沒有爲任何mc設置位置,所以你應該確保'thumb' movieclip從不相互重疊。 – Moorthy