0
我目前正試圖通過一個數組和一個循環做出動態菜單。所以當有人點擊數組中的第一個項目「menu_bag_mc」時,它將鏈接到內容「menu_bag_mc_frame」(或某個名字,這個名字將是這個數組唯一的),這是另一個將加載的動畫片段。下面是我的代碼至今:從數組動作創建變量3
//right here, i need to make a variable that I can put in the "addchild" so that
//for every one of the list items clicked, it adds a movieclip child with
//the same name (such as menu_bag_mc from above) with "_frame" appended.
//I tried the next line out, but it doesn't really work.
var framevar:MovieClip = menuList[i] += "_frame";
function createContent(event:MouseEvent):void {
if(MovieClip(root).currentFrame == 850) {
while(MovieClip(root).numChildren > 1)
{
MovieClip(root).removeChild(MovieClip(root).getChildAt(MovieClip(root).numChildren - 1));
}
//Here is where the variable would go, to add a child directly related
//to whichever array item was clicked (here, "framevar")
MovieClip(root).addChild (framevar);
MovieClip(root).addChild (closeBtn);
}
else {
MovieClip(root).addChild (framevar);
MovieClip(root).addChild (closeBtn);
MovieClip(root).gotoAndPlay(806);
}
}
有沒有辦法從數組做出了獨特的可變(不管它是什麼),這樣我可以命名後,一個movieclip所以它會加載新的影片剪輯?謝謝
這些是我得到的以下錯誤: 1120:訪問未定義的屬性i。/1118:將靜態類型的對象隱式強制爲可能無關類型的類。這是指第三行代碼,frameVarClass – steve 2010-05-26 03:30:13
我認爲很明顯,menuList引用MovieClips,因爲我說一個示例項目是「menu_bag_mc」,並說當你點擊每個數組項時,它應該鏈接到一個「movieclip這將加載。「不過,下次我會更具體。 – steve 2010-05-26 03:40:07
我剛更新了那一行。它現在應該工作。我只是想知道menuList包含什麼類型,因爲你說menuList [i] + =「_frame」。您無法將字符串添加到MovieClip。 – 2010-05-26 04:40:09