2 Replies Latest reply on Oct 25, 2009 7:07 AM by Gregory Lafrance

    How To embed mxml into another mxml in flex

    andri.setyawan

      hello

       

      i try to embed mxml to another mxml....

      my case is like  this...

      i have 1 mxml (one.mxml).. then i want to embed another mxml into one.mxml......

      in one.mxml i use canvas for another mxml....then i use button to call another mxml.......(i hope my algoritm not wrong...)

       

       

      ii always got err like this...

       

      ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.

      at flash.display::DisplayObjectContainer/getChildIndex()

      at mx.managers::SystemManager/getChildIndex()[C:\autobuild\3.2.0\frameworks\projects\framewo rk\src\mx\managers\SystemManager.as:1652]

      at mx.managers::SystemManager/mouseDownHandler()[C:\autobuild\3.2.0\frameworks\projects\fram ework\src\mx\managers\SystemManager.as:3465]

      can you help me....

       

       

      thanks before.......n_n

        • 1. Re: How To embed mxml into another mxml in flex
          kabalweg

          What you can do is create a component using the mxml file you want to embed. Once a component is created, you can drag and drop it just like any other controls in Flex and that component is accessible under the Component -> Custom window.

          1 person found this helpful
          • 2. Re: How To embed mxml into another mxml in flex
            Gregory Lafrance Level 6

            If this post answers your question or helps, please mark it as such.

             

            You seem to be calling getChildIndex() (either directly or indirectly), but it seems like however you are "embedding" the other MXML page you may not be doing it right.

             

            Let's say you have test.mxml (main app that contains one.mxml), one.mxml (component that contains two.mxml), and component two.mxml:

             

            ---------- test.mxml ----------

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
              xmlns:ns1="*">
              <ns1:one/>
            </mx:Application>

             

            ---------- one.mxml ----------

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="500" height="200"
              backgroundColor="0xFF0000" xmlns:comp="*">
              <mx:Label x="0" y="0" text="This is MXML 'one'" fontSize="30" color="0xFFFFFF"/>
              <comp:two horizontalCenter="0" verticalCenter="0"/>
            </mx:Canvas>

            ---------- two.mxml ----------

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="200" height="100"
              backgroundColor="0x0000FF">
              <mx:Label text="This is MXML 'two'" fontSize="20"/>
            </mx:Canvas>

            1 person found this helpful