开发者

Tab Navigator in a Title window : issue

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(canvas开发者_如何学编程3);
                   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>


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:

var form:MyForm = MyForm(PopUpManager.createPopUp(this, MyForm, true));
PopUpManager.centerPopUp(MyForm);

Finally, in your MyForm.mxml component, add the event listener for closing. The method should only need to call: PopUpManager.removePopUp(this);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜