8 Replies Latest reply on Oct 26, 2011 3:45 AM by willise414


    willise414 Level 1

      I need some guidance on using flashvars to load separate URL's.


      I have a website that has two links on it, LinkA and LinkB. Both of these links require the user to login, so they both point to my login.swf and login.php.


      One the user logs in, how can I let the login SWF know which link to direct the user to?


      I know I can use separate SWF's for each link on the main page, but as I add more links, it will become very cumbersome, so I'd like to do it with flashvars.


      So in essence, I want to pass either LinkA or LinkB to the login SWF, and then once the user completes the login, redirect them to the appropriate content based on their LinkA or LinkB selection initially.


      I hope that makes sense!


      Thank so much!!

        • 1. Re: Flashvars
          Flex harUI Adobe Employee

          You can add different flashvars to the htmlwrappers, or pass information on the URL to the SWF.  Both will get picked up and be available in the Application.parameters.

          1 person found this helpful
          • 2. Re: Flashvars
            willise414 Level 1

            Hi there,


            Thanks for the quick reply.


            I understand that the flashvars will get picked up by the Application.parameters tag, but It would really help if I could see an example. How do I set it up so that the original HTML page sends the link to the flashvars?


            THanks again!!

            • 3. Re: Flashvars
              Flex harUI Adobe Employee

              In the index.template.html, there is the line:              var flashvars = {};


              Populate that object with something useful like

                  var flashvars =


              And the Application.parameters.link will be “linkA”

              1 person found this helpful
              • 4. Re: Flashvars
                willise414 Level 1

                You'll have to forgive my ignorance here, but I can't wrap my head around this.


                In the login.html, I will set up the flashvars to something like this:


                <param name = flashvars value="linkA=URLofLinkA&linkB=URLofLinkB">


                That doesn't seem correct to me.


                In the Flex login app, I would put Application.application.parameters.LinkA


                I guess my understanding of flashvars is very limited. I can't seem to understand how the link that the user clicks on in a pure HTML only page will populate a flashvar.


                Sorry for my ignorance.

                • 5. Re: Flashvars
                  Flex harUI Adobe Employee

                  I think we don’t understand the problem.  It might be that you don’t want to use flashvars at all and just use URL parameters.  In the links you would put in something like:



                  Go to A
                  Go to B


                  Then if login.html loads login.swf, you would use BrowserManager in your app to parse off the link from the URL.  See the doc examples for BrowserManager.

                  • 6. Re: Flashvars
                    willise414 Level 1



                    I've been trying to figure this out for the last several days to no avail.


                    Here is an example of what I have so far:


                    My URL of the HTML page is www.mydomain.com?page=google


                    My understanding is that the "?page=google" sets teh URL variable to be passed to flex.


                    This is my MXML application to test it:


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

                    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"


                                                     xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="init()">


                                        <!-- Place non-visual elements (e.g., services, value objects) here -->




                                                  import flash.net.*;

                                                  import flash.net.navigateToURL;


                                                  import mx.core.FlexGlobals;






                                                  private var page:String;


                                                  private function init():void




                                                            page = FlexGlobals.topLevelApplication.parameters.page;


                                                            output.text = "test: " +page + "\n"




                                                  protected function redirect(event:MouseEvent):void


                                                            page = FlexGlobals.topLevelApplication.parameters.page;


                                                            var src:URLRequest = new URLRequest("http://www.google.com");

                                                            var temp:URLRequest = new URLRequest("http://www.msn.com");

                                                            var last:URLRequest = new URLRequest("http://www.cnn.com);


                                                            if (parameters.page == "google")


                                                                      navigateToURL(src, "_blank");




                                                                      navigateToURL(temp, "_blank");











                              <s:Button x="88" y="70" label="FlashVar" id="flashvar" enabled="true" click="redirect(event)" />


                              <s:TextArea id="output" width="300" height="76" x="264" y="70"/>

                              <s:Label x="88" y="231"  width="101" height="37" text="{page}"/>






                    In my text area, the flashvar is never appearing, so unless my coding is wrong, the variable os not getting sent to the application. When I click the button, I get redirected to msn.com - another clear indication my variable is not getting received.


                    Can anyone see what I'm doing wrong here?


                    Thanks so much!!

                    • 7. Re: Flashvars
                      Flex harUI Adobe Employee

                      I think your first assumption isn’t true.  Hitting www.mydomain.com/index.html?page=google only sets URL params for the html page.  In the html, a SWFObject is created and given flashvars and other parameters and there is no default behavior that copies the URL params from the html to the SWFObject.  You can write JS to do so, or you can change to use BrowserManager.  Then you’d hit www.mydomain.com/index.html#page=google and the BrowserManager code would pick up the page=google and let you handle it in an event.  You would not use Application.parameters.

                      • 8. Re: Flashvars
                        willise414 Level 1



                        I'll try to rewrite the code and see if it works.


                        First, I have to research BrowserManager