6 Replies Latest reply on Oct 1, 2009 12:31 PM by Alex-SM

    calling mxml page

    Alex-SM

      Hi,

       

      What's the best way to call another mxml file in flex? Can I use ViewStack to call another mxml file?

       

      Thanks,

      ASM

        • 1. Re: calling mxml page
          ShardulSingh Level 3

          Its not neccessary to use viewStack. You can decide as per your need.

           

          http://examples.adobe.com/flex3/componentexplorer/explorer.html

           

          Go to the 'Visual Component' and under that 'Containers'.

          Here you can find the source code as per your need.

          Let me know if you have any issue.

           

           

           

           

           

          with Regards,

           

          Shardul Singh Bartwal

          • 2. Re: calling mxml page
            Alex-SM Level 1

            Hi Shardul,

             

            I've look at the examples but couldn't find a proper example that match with what I need.

             

            I have an application mxml file with bunch of TitleWindow mxml files.  I need to know how to call each TitleWindow mxml file from another one.

             

             

            main.mxml ---> TitleWindow1.mxml  --> TitleWindow2.mxml -->

             

            Thanks,

            ASM

            • 3. Re: calling mxml page
              ShardulSingh Level 3

              Do you want to Call these two TileWindows at the same place, one will visible at a time.

              Or you want to show another TileWindow on the Click of the First one?

              • 4. Re: calling mxml page
                Alex-SM Level 1

                Hi,

                 

                I want to show another TileWindow (seperate mxml file) on the Click of the First one?

                 

                Thanks,

                Ali

                • 5. Re: calling mxml page
                  ShardulSingh Level 3

                  Hi,

                  The viewstack is perfect for this scenario.

                  You can find the domo Application code for the same.

                   

                  MainApplication.mxml

                  <?xml version="1.0" encoding="utf-8"?>

                  <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"

                  xmlns:local="*">

                        <mx:ViewStack width="500" height="500">

                              <local:MyComponentTileWindow1 width="100%" height="100%"/>

                              <local:MyComponentTileWindow2 width="100%" height="100%"/>

                        </mx:ViewStack>

                  </mx:Application>

                   

                   

                  MyComponentTileWindow1

                  <?xml version="1.0" encoding="utf-8"?>

                  <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"

                        width="400" height="300"

                        title="TileWindow1">

                        <mx:Script>

                             <![CDATA[

                                   import mx.containers.ViewStack;

                                   private function navigateToSecondWindow():void

                                   {

                                         var vstk : ViewStack = this.parent as ViewStack;

                                         vstk.selectedIndex = 1;

                                   }

                             ]]>

                        </mx:Script>

                        <mx:Label text="TileWindow1"/>

                        <mx:Button label="Go To TileWindow2" click="navigateToSecondWindow()"/>

                  </mx:TitleWindow>

                   

                  MyComponentTileWindow2

                  <?xml version="1.0" encoding="utf-8"?>

                  <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"

                        width="400" height="300"

                        title="TileWindow2">

                        <mx:Script>

                              <![CDATA[

                                    import mx.containers.ViewStack;

                                    private function navigateToFirstWindow():void

                                   {

                                         var vstk : ViewStack = this.parent as ViewStack;

                                         vstk.selectedIndex = 0;

                                   }

                              ]]>

                        </mx:Script>

                        <mx:Label text="TileWindow2"/>

                        <mx:Button label="Go To Window 1" click="navigateToFirstWindow()"/>

                  </mx:TitleWindow>

                   

                   

                   

                   

                   

                  with Reagrds,

                  Shardul Singh Bartwal

                  • 6. Re: calling mxml page
                    Alex-SM Level 1

                    Thank you so much for the info.

                     

                    I have another topic question and I appreciate if you can help me.

                     

                    There is a compiled flex application (swf file) that I wan to load it into html using javascript. Once the swf file is loaded I need to call APIs defined in the swf files. This has been tested successfuly in a single html page.

                     

                    My question is as follow: Can I load the swf file into a popup window (not the main html) and then access the swf file APIs in the main page?

                     

                     

                    ---------------------------------------------------------------------------------

                    popup window

                     

                    <div id="popup"></div>

                    <script type="text/javascript">
                    function createSWFObject()
                    {
                        var SWFObject = document.createElement("object");
                        SWFObject.setAttribute("type","application/x-shockwave-flash");
                        ...
                        var movieParam = document.createElement("param");
                        movieParam.setAttribute("name","movie");
                        ... 
                        return SWFObject;
                    }
                    var displayContainer = document.getElementById("popup");
                    displayContainer.appendChild(createSWFObject());
                    </script>

                    -------------------------------------------------------------------------------------

                    main window

                     

                    calling APIs within swf file

                    ------------------------------------------------------------------------------------