2 Replies Latest reply on Dec 6, 2007 2:41 AM by Gregory Lafrance

    how to include mxml in a panel

    lucky_raga
      hi,

      I have a set of mx:Panels
      The content to be displayed inside each panel is structured in an mxml file.
      How do i reference or place this mxml file inside the panels.


      Thanks,
      Lucky
        • 1. Re: how to include mxml in a panel
          atta707 Level 2
          what do you mean by contents? Are they components or modules.

          if components, you just have to declare xmlnm property on the application that contains the panel:

          xmlns:MyComp="myComponents.*">

          where myComponents is the folder where you have your component.

          then in your panel just do <MyComp:MyComp1/>

          If you're working with modules, please refer to the docs for how to load them.

          ATTA
          • 2. Re: how to include mxml in a panel
            Gregory Lafrance Level 6
            ---------------------------- components/MyVBox1.mxml -----------------------------
            <?xml version="1.0" encoding="utf-8"?>
            <mx:VBox xmlns:mx=" http://www.adobe.com/2006/mxml" width="100%" height="100%">
            <mx:Button id="myButton1" label="MyButton1"/>
            <mx:Button id="myButton2" label="MyButton2"/>
            </mx:VBox>
            ------------------------------------------------------------------------------
            ---------------------------- components/MyVBox2.mxml -----------------------------
            <?xml version="1.0" encoding="utf-8"?>
            <mx:VBox xmlns:mx=" http://www.adobe.com/2006/mxml" width="100%" height="100%">
            <mx:CheckBox id="myCheckbox1" label="MyCheckbox1" selected="true"/>
            <mx:CheckBox id="myCheckbox2" label="MyCheckbox2" selected="false"/>
            </mx:VBox>
            ------------------------------------------------------------------------------
            -------------------- SimpleExampleApp.mxml ---------------------
            <?xml version="1.0"?>
            <!-- menus/EventListener.mxml -->
            <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
            xmlns:comp="components.*" initialize="init()" width="500" height="500">
            <mx:Script>
            <![CDATA[
            import components.MyVBox2;
            private function init():void{
            myPanel2.addChild(new MyVBox2());
            }
            ]]>
            </mx:Script>

            <mx:Panel id="myPanel1" backgroundColor="#DB8686" width="200" height="200">
            <comp:MyVBox1 />
            </mx:Panel>
            <mx:Panel id="myPanel2" backgroundColor="#9F86DB" width="200" height="200"/>
            </mx:Application>