0
我有一个循环,通过书中的数据并显示它。这本书在布局上并不一致,所以我试图用两种不同的方式展示它。第一种方法(正常工作)是将该部分的文本加载到面板并显示它。第二种方法是创建一个新面板(面板创建正常),然后将可折叠面板(嵌套)添加到该面板。这是来自else循环的代码。动态地将容器添加到动态容器中
else if (newPanel == false){
// simpleData is just for the title bar of the new panel
// otherwise the panel has no content
var simpleData:Section = new Section;
simpleData.section_letter = item.section_letter;
simpleData.letter_title = item.letter_title;
simpleData.section_id = item.section_id;
simpleData.title = item.title;
simpleData.bookmark = item.bookmark;
simpleData.read_section = item.read_section;
var display2:readPanel02 = new readPanel02;
//item is all the data for the new text
display2.id = "panel"+item.section_id;
//trace(display2.name);//trace works fine
// set vars is how I pass in the data to the panel
display2.setVars(simpleData);
studyArea.addElement(display2); // displays fine
newPanel = true;
//this is where it fails
var ssPanel:subSectionPanel = new subSectionPanel;
//function to pass in the vars to the new panel
ssPanel.setSSVars(item);
//this.studyArea[newPanelName].addElement(ssPanel);
this["panel"+item.section_id].addElement(ssPanel);
我得到的错误是:在components.readTest没有找到物业panel4.4并没有默认值:的ReferenceError:错误#1069。
我曾尝试设置“名称”属性而不是“id”属性。任何帮助将不胜感激。我很难过。谢谢。
我不明白你要完成的任务。你只是想显示书籍数据?不要专注于如何,但什么。从一瞥你的代码我可以告诉你,你在做什么远非最佳。 –
@J_A_X我不知道你是否看到我自己回答。你对那里的代码有什么看法?我对优化知之甚少,所以我想知道你的意见。 – ChristopherMarcel
再一次,我不能评论,因为我不知道你想用这些完成什么。你试图解决什么问题? –