我有两个类,VideoPod和RemotePod,RemotePod继承自VideoPod。如果没有显示这些类的所有代码,basicall这里的VideoPod的一部分:为什么将这些对象放入MXML中打破了这个功能?
public function showPanel():void {
if (!pnl.visible) {
pnl.visible = true;
pnl.addElement(removeElement(vg));
}
}
.
.
.
<s:Panel id="pnl" width="100%" height="100%" fontWeight="normal" visible="false" />
<s:VGroup id="vg" left="0" resize="onResize()" right="0" top="0" bottom="0">
和这里的RemotePod的一部分:
private function onCreationComplete():void {
m_tmrHeartbeat.addEventListener(TimerEvent.TIMER, checkPulse);
var arrBtns:Array = new Array(4);
for (var i:int = 0; i < arrBtns.length; i++) {
arrBtns[i] = new Button();
arrBtns[i].width = 28;
arrBtns[i].height = 25;
arrBtns[i].top = 10;//-28;
}
arrBtns[0].right = 10;
arrBtns[0].setStyle("icon", Images.PATH + "view-fullscreen-3.png");
arrBtns[0].addEventListener(MouseEvent.CLICK, maximize);
.
.
.
for each (var btn:Button in arrBtns) {
addElement(btn);
}
m_lblSize.right = 154;
m_lblSize.top = 18;//-20;
m_lblSize.text = FULLSCREEN;
addElement(m_lblSize);
其中onCreationComplete()被调用为RemotePod creationComplete事件。几分钟前,我尝试将RemotePod中的按钮和标签移动到实际的MXML中,但这打破了showPanel()函数。它提出的错误基本上有以下信息:“在本组中找不到vg”。 (VideoPod继承自s:Group。)
我不明白。我也开始测试vg在运行时的宽度,它显然只是停留在0.什么是造成这种情况的晦涩语言功能?谢谢!
我不认为RemotePod可以*有* MXML,除非您已经将VideoPod作为模板组件编写。因此,查看两者的代码以查看这是否甚至可以正常工作非常重要。另外,你不应该在creationComplet中添加子元素,而是在createChildren覆盖中。 –