0
我是根據從XML文件獲得的信息動態創建面板,但是我在向這些面板添加按鈕時遇到問題。這些buttoms也是基於從XML文件中獲取的信息創建的。問題似乎是我給面板一個Id名稱的方式。任何你能給的幫助都會很棒。將按鈕添加到動態創建的面板
private function sidebar():void{
for each (value in [email protected])
{
var myInstance4:spark.components.Panel = new spark.components.Panel();
myInstance4.title = value;
myInstance4.id = value;
sidebarbox.addChild(myInstance4);
Alert.show(myInstance4.id)
for each (value2 in [email protected])
{
var myInstance3:spark.components.Button = new spark.components.Button();
myInstance3.label = value2;
myInstance3.addEventListener("click",changeIt);
myInstance3.id=value2;
// value.addChild(myInstance3);
// value.addElement(myInstance3);
}
}
}