3 Replies Latest reply on Nov 2, 2007 12:40 AM by Greg Dove

    recording document.location.href

    AlienDev211
      Setup: I am using Flash MX, we have created a flash based survey that is passing information to a pearl script. The form is working but more information is needed. i need information about the url that they used our survey. we have a very large website and we need to know where they were and how they got there kindof thing. ill take just where they were...that is enough for me..it seems like an easy deal right......wrong..

      i have tried the following:
      formData.origurl = _root._url;
      formData.origurl = getURL('javascript:document.location.href')

      and a number of other ways to pass it using functions and javascript from the .html file etc. I am frustrated and need some assistance. basically the answer i NEED is ( formData.origurl = document.location.href ) yea...actionscript variable = javascript answer.

      If anyone thinks they could help. Please contact me. Best way is either reply to this forum...or skype/msn or something.....

      skype = michael.youngblood1
      msn = mikkie_youngblood@hotmail.com
      yahoo = mikkie211
      aol = mikeryb16

      i have them all on at all times....please help
        • 1. Re: recording document.location.href
          Greg Dove Level 4
          If you're publishing for version 6 (MX) you won't be able to use ExternalInterface to communicate with javascript (which is a pity because it makes things a lot easier). That's only available from player versions 8+. If you want to be compatible with player version 6 players you should consider this approach if you want to use javascript:
          http://www.permadi.com/tutorial/flashjscommand/index.html

          (you can call a javascript function with getURL, but it doesn't return a value, which is what you want here, so, unless you code your getURL to correctly target your swf for the setVariable call to return the result to actionscript, then you probably should use the approach above).

          Hope that helps.
          • 2. Re: recording document.location.href
            AlienDev211 Level 1
            Yea thats the answer I thought I was going to get. Lets say I was able to get Flash cs3. What would be the simplified answer with this externalinterface command. I need this answer to get approval from the boss.
            • 3. recording document.location.href
              Greg Dove Level 4
              Flash CS3 won't help you if you want to publish for version 6 player, because if its a requirement to target that player to be more compatible, then its the instruction set for that player that's the constraint. But flash 8/as2 is (IMO) the 'norm' now. Probably flash player 9 is now not too far behind. Adobe has the player penetration stats on their website if you need that info for your boss.

              Just to clarify/reiterate: its entirely possible to do this with MX, and its not really too difficult. You just need to use the approach I outlined. ExternalInterface just makes it easier.

              For ExternalInterface it would be something like:

              in actionscript:
              if (ExternalInterface.available) {
              var thisPage_href = ExternalInterface.call("getPageLocation");

              } else {
              // no javascript... can't get the value
              }

              and in javascript on every page that contains the survey:

              function getPageLocation() {
              return document.location.href;
              }


              Of course the other way to do it you might want to consider (especially if all your pages and flash embedding is being generated by a CMS and is not static html) is to have a flashvar on the embedding code for the flash that passes in the url of the containing page. This way you don't need to use javascript at all - the value would just 'be there'.
              http://livedocs.adobe.com/flash/9.0/main/00000668.html#wp119361
              http://www.impossibilities.com/blog/flashvarstip2.php