标题窗口中的选项卡导航器:问题
我在此处向标题窗口添加一个选项卡导航器。标题窗口关闭后,可以使用按钮重新打开它。但是以这种方式第二次打开标题窗口时,选项卡导航器的子级内容(此处为标签)不可见。
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()"
<mx:TabNavigator x="68" y="68" width="200" height="200" id="tabNavig" historyManagementEnabled="false">
</mx:TabNavigator>
<mx:Script>
<![CDATA[
import mx.events.CloseEvent;
import mx.managers.PopUpManager;
public function init():void{
tabNavig.removeAllChildren();
tabNavig.addChild(canvas1);
tabNavig.addChild(canvas2);
tabNavig.addChild(canvas3);
expenseTitle.showCloseButton = true;
expenseTitle.addChild(tabNavig);
PopUpManager.addPopUp(expenseTitle,this,false);
expenseTitle.addEventListener(CloseEvent.CLOSE,titleWindow_close);
}
private function titleWindow_close(evt:CloseEvent):void
{
expenseTitle.removeAllChildren();
PopUpManager.removePopUp(expenseTitle);
}
]]>
</mx:Script>
<mx:TitleWindow id="expenseTitle" >
</mx:TitleWindow>
<mx:Canvas id="canvas1" x="476" y="117" width="200" height="200" >
<mx:Label x="64" y="93" text="Label1"/>
</mx:Canvas>
<mx:Canvas id="canvas2" x="244" y="310" width="200" height="200" >
<mx:Label x="111.5" y="29" text="Label2"/>
</mx:Canvas>
<mx:Canvas id="canvas3" x="697" y="117" width="200" height="200" >
<mx:Label x="59" y="79" text="Label3"/>
</mx:Canvas>
<mx:Button x="78" y="310" label="Button" click="init()"/>
</mx:Application>
I am adding a tab navigator to a title window here. Once the title window is closed, it can be reopened using the button.But on opening the title window second time in this manner ,the content of the children of the Tab navigator(here, a label) is not visible.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()"
<mx:TabNavigator x="68" y="68" width="200" height="200" id="tabNavig" historyManagementEnabled="false">
</mx:TabNavigator>
<mx:Script>
<![CDATA[
import mx.events.CloseEvent;
import mx.managers.PopUpManager;
public function init():void{
tabNavig.removeAllChildren();
tabNavig.addChild(canvas1);
tabNavig.addChild(canvas2);
tabNavig.addChild(canvas3);
expenseTitle.showCloseButton = true;
expenseTitle.addChild(tabNavig);
PopUpManager.addPopUp(expenseTitle,this,false);
expenseTitle.addEventListener(CloseEvent.CLOSE,titleWindow_close);
}
private function titleWindow_close(evt:CloseEvent):void
{
expenseTitle.removeAllChildren();
PopUpManager.removePopUp(expenseTitle);
}
]]>
</mx:Script>
<mx:TitleWindow id="expenseTitle" >
</mx:TitleWindow>
<mx:Canvas id="canvas1" x="476" y="117" width="200" height="200" >
<mx:Label x="64" y="93" text="Label1"/>
</mx:Canvas>
<mx:Canvas id="canvas2" x="244" y="310" width="200" height="200" >
<mx:Label x="111.5" y="29" text="Label2"/>
</mx:Canvas>
<mx:Canvas id="canvas3" x="697" y="117" width="200" height="200" >
<mx:Label x="59" y="79" text="Label3"/>
</mx:Canvas>
<mx:Button x="78" y="310" label="Button" click="init()"/>
</mx:Application>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的 MXML 结构完全错误。
您需要将 MXML 组件(例如您计划用作弹出窗口的 TitleWindow)与主应用程序标记分开。
例如,创建一个单独的 MXML 组件,名为 MyForm.mxml。该组件应该是带有选项卡导航器的 TitleWindow。选项卡导航器应将 3 个 Canvas 组件作为子组件。
然后,在您的主应用程序逻辑中,按钮应启动弹出窗口 MyForm.mxml,如下所示:
最后,在 MyForm.mxml 组件中,添加用于关闭的事件侦听器。该方法只需调用:
PopUpManager.removePopUp(this);
The structure of your MXML is completely wrong.
You need to keep MXML components (e.g. a TitleWindow that you plan on using as a popup) separate from your main application markup.
For example, create a separate MXML component, called MyForm.mxml. This component should be a TitleWindow with a Tab Navigator. The Tab Navigator should have the 3 Canvas components as children.
Then, in your main application logic, the Button should launch the pop up, MyForm.mxml like so:
Finally, in your MyForm.mxml component, add the event listener for closing. The method should only need to call:
PopUpManager.removePopUp(this);