7 Replies Latest reply on May 3, 2009 6:08 PM by gienie87

    Load and open swf in new window


      Hi everyone,


      I have 2 flex applications named login and game. When the user logged in, I want the login swf to load the game swf and open it in a new window once it finished loading. I tried popup manager and title window but they only made the swf popped up INSIDE the app itself (which is the login swf). What I really want is to be able to load and open the game swf in a brand new popup window.


      Please help. Thanks.

        • 1. Re: Load and open swf in new window
          ATIF FAROOQ Level 3


             if you are talking about opening game.swf in separate browser popup window . then you may need to call such javascript through flex external interfacea


          var popup = window.createPopup( );
          var bod = popup.document.body;
          bod.style.border = "3px solid #ff8800";
          bod.style.padding = "2px";
          bod.style.backgroundColor = "lightyellow";
          bod.innerHTML = 
            <p style='font-family:Arial, sans-serif; font-size:10px'>Some popup text.</p>";
          popup.show(100, 100, 100, 26, document.body);"
          • 2. Re: Load and open swf in new window
            gienie87 Level 1

            Hi Atif thanks for the reply!


            But can you explain more on how to call javascript through flex external interface?


            in flex

            public function loadSwfInNewWindow():void

                 //load game.swf

                 //call javascript to open it in new browser?



            Sorry for being a noob =)


            • 3. Re: Load and open swf in new window
              ATIF FAROOQ Level 3

              in Flex you may write something similar




              in javascript you create following function and replace url test.html with

              your own


              function newPopup(){




              test.html will contain your game.swf with its html wrapper.

              • 4. Re: Load and open swf in new window
                Barna Biro Level 3

                Hi there,


                The sad thing about this "swf in a new window" is that most of the browser are blocking pop-ups by default and some even have javascript disabled. It's really not user friendly to pop-up a new window when the user clicks a button or something. I for one would definitely close your application and never visit it again ( no matter what it offers ).


                Instead, you should really stick to the PopUpManager.


                With best regards,

                Barna Biro

                • 5. Re: Load and open swf in new window
                  Gregory Lafrance Level 6

                  Loggin in is a classic example of when to use states.


                  The base state will be your app, and the "login" state will be your login state. Set the application currentState to 'login' in the creationComplete event.


                  <?xml version="1.0"?>
                  <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                      <mx:State name="login">
                        <mx:RemoveChild target="{vb}"/>
                            <mx:FormHeading label="Login"/>
                            <mx:FormItem label="Username:">
                            <mx:FormItem label="Password:">
                              <mx:TextInput displayAsPassword="true"/>
                              <mx:Button label="Login" click="this.currentState=''"/>
                    <mx:VBox id="vb" width="100%" height="100%">
                      <mx:Label text="Login Done - Now in Main App"/>   

                  • 6. Re: Load and open swf in new window
                    ntsiii Level 3

                    navigateToURL() has its uses but please be careful not to create an html applicatuion using Flex.  That's like hitching a Ferrari to a team of mules.



                    • 7. Re: Load and open swf in new window
                      gienie87 Level 1

                      Thanks for everyone's reply.


                      I initially used states for the login and game. But my boss said that he wishes to have them run in different browser, as in you login, game open and pop up in new browser. Then I changed to popupmanager, but it only pop up the game inside the main app, which is still in the same browser and not a new one. Now i am trying the javascript method. Hope that will settle it.