3 Replies Latest reply on Nov 7, 2007 5:40 AM by Greg Dove

    Get current URL

    Happiest Camper
      The overview is that I am making a navigation bar with 12 choices, each choice has a prefix of the current airport (LAX, SFO, etc.). There are many airports, so I am trying to not make a navigation SWF for each airport. Instead I am trying to get the prefix from the current html page (which loads from the backend) which will have that correct prefix on it.

      Therefore, if I am in "lax-home.html", I want the program to read that, take off the first three letters ("lax") and make that a variable. That way, when I select anything in the navigation it will put those first three letters at the front of it and go to the URL within that airport. I don't know if I can do this. I am trying to avoid making a unique navigation for each airport, when all that changes is the first three letters. Let me know if you need any clarification. Thanks for any help!
        • 1. Get current URL
          Greg Dove Level 4
          There are two basic ways to do it. You can have the choice passed in as a flashvar in the flash embedding code for the page.... or you can use ExternalInterface to call a javascript function in the page to return the location object and extract the value using string methods. If your html is being generated by a server side script and is not flat html then the first approach is probably the best, because it potentially covers the rare group that have javascript switched off, but still allow flash content (I suspect this is extremely rare though).
          If you're using a javascript embedding method (e.g. swfobject, activecontent.js etc) then you can also add the flashvar just before you call the embedding javascript function, using javascript alone.


          • 2. Re: Get current URL
            Happiest Camper Level 1
            I gave up on bringing in the URL and parse it into a string, there is too much I don't understand. I put in two commands in the HTML where the Flash movie is sitting:

            1. <param name="FlashVars" value="airport=sbn"/>
            2. and in <embed src I put in, Flashvars="airport=sbn"

            "airport" is the variable in Flash (it is called as "_level0.airport" in the Flash file) and "sbn" is the variable definition for 12 of the files. I will just find "sbn" and replace it with the new airport name in the next set. It's not very slick, but it's better than having to create a new navigation for every airport. Thanks for the help.
            • 3. Re: Get current URL
              Greg Dove Level 4
              You're welcome. That approach was essentially the first option I suggested. Its easier if your html is being generated by a server side script, because you can have the script drop the correct value for the flashvar in place. If its separate html pages its manual editing... but still not too much work.