我在这个类中有一个文档类,我动态创建影片剪辑,将它们存储在一个数组中,最后使用 addChild 将其添加到舞台。没关系,问题是虽然我试图通过数组删除movieClips,但它抛出了一个错误:
1034:类型强制失败:无法将 []@26be1fb1 转换为 flash.display.DisplayObject。
这是我的代码:
// Note i have declared the array outside the function, so that's not an issue
function x (e:MouseEvent){
if (thumbnails.length !== 0){ // Determine if any movieclips have already been created on stage and delete them
for(var ctr:int = 0; ctr < thumbnails.length;ctr++ ){
removeChild(thumbnails[ctr]);
}
}
for (var i: int = 0;i < userIput; i++){ // Loop through and create instances of symbol
var thumb:Thumbnail = new Thumbnail();
thumb.y = 180; // Set y position
thumb.x = 30 + ((thumb.width + 10) * i);
addChild(thumb);
thumbnails[i] = [thumb]; // Add to array
}
}