1 Reply Latest reply on May 11, 2007 5:55 PM by jinx82002

    Calling another MXML file from One MXML file

      HI All,
      I want to call "datagrid" mxml file which i designed using desginer in Flex 2 builder. That Mxml file has Panel as a container & Datagrid control .

      I also created "main" Mxml file which contains panel as container & the button as its children.

      My intension is to call "datagrid" mxml screen when i press button on the "main" mxml file. I have written Eventhandler () in the
      "main" mxml file which would be called when i press button.

      what command or code should i write in the "main" mxml file to display "datagrid" mxml screen when i press button.
      As well as when i close "datagrid" mxml screen,it should display "main" mxml screen

      thanks in advance
        • 1. Re: Calling another MXML file from One MXML file
          jinx82002 Level 1
          Hey sank22,

          Did you make datagrid.mxml a component? When I build, I tend to store my custom components in a folder under main.mxml. Here's how I'd do it:

          1. Make new folder "components" for example.

          2. File > New > MXML Component, call it DG (its a class so name it with caps) for example, dump datagrid code in here and make sure it's in the components folder.

          3. In main.mxml in the Application tag, enter an xml name space for your custom component. In this example:
          Also, in your script, don't forget to import the full path:
          import components.DG;

          I would wait for the button click on main.mxml, then addChild() in the Panel to bring in the DG. In the Eventhandler() function on main.mxml put:
          var dg:DG = new DG();

          I would probably also make dg dispatch a close event when the user hits the close button and listen for it on the main.mxml, then you can removeChild etc.

          Hope this helped