5 Replies Latest reply on Nov 14, 2009 9:57 AM by ChromeBullet

    ExternalInterface help with grabbing URL

    ChromeBullet

      This should be simple, but....

      Objective:
      I have a flash menu that needs to play a different scene depending on which page it is embedded into. So I need the it to grab the URL of the html page it is on and do some simple test on it to figure out what scene it should be on. *For the record, I tried to do it without scenes but the frame jumping started doing some cracked out things

      Code: (on a single empty frame in Scene 1)
      import flash.external.ExternalInterface;

      var urlPath;
      urlPath = ExternalInterface.call("window.location.href.toStr  ing()");
      getURL("javascript:alert('"+urlPath+"');");


      if (urlPath == "http://www.awesome.com/Portfolio/portfolio.html"){
      gotoAndPlay("Scene 3", "portfoliopage");
      } else if (urlPath == "http://www.awesome.com/Resume/resume.html"){
      gotoAndPlay("Scene 4", "resumepage");
      } else if (urlPath == "http://www.awesome.com/Contact/contact.html"){
      gotoAndPlay("Scene 5", "contactpage");
      }
      //else goes to Scene 2, frame 1

       

      *urls here have been changed

      Problem:
      Somehow, my urlPath isn't getting the correct value, and therefore the if-else latter isn't functioning appropriately. I am posting the website on my test server, so the http addresses are correct, and the if-else latter functions perfectly when I just change the conditions to 'true'/'false', so neither is the problem. The problem is that the alert shows me that the value of urlPath is undefined, and so then all conditions in the latter evaluate to false.

      I've searched high and low for answers, following other threads on here and tutorials else where, but for the life of me I can't figure out what's going wrong.

      PLEASE  HELP!