2 Replies Latest reply on Apr 11, 2008 1:37 AM by mistabello

    Local javascript call

    mistabello
      I'm working on a tutorial project for a client that wants to be able to run the app from a CD or from a web site.

      I need the app to do two things (locally). Scroll the browser to the top of the window. Go to another URL. Simple enough?

      To scroll to the top of the window, I added this javascript handler into the Flex-generated HTML wrapper:
      function topscroll()
      {
      scroll(0,0);
      }

      Which I am calling from Flex with:
      private function gotop():void {
      ExternalInterface.call("topscroll()");
      }

      To go to a URL, I'm using:
      private function startover():void {
      navigateToURL(new URLRequest(Application.application.url), '_self');
      }

      Both of these work perfectly after I upload all the files onto a website. But from a CD or hard drive, I get all kinds of sandbox errors. I don't see the risks in talking to JS in the same HTML file containing the Flex Object.. Why is it blocking me from doing so?

      The errors look like this:
      "Adobe Flash Player has stopped a potentially unsafe operation.

      The following local application on your computer or network:
      /Users/ryan/Desktop/Tutorial/bin-release/Tutorial.swf

      is trying to communicate with this Internet-enabled location:
      /Users/ryan/Desktop/Tutorial/bin-release/Tutorial.html"

      followed by "SecurityError: Error #2060: Security sandbox violation: ExternalInterface caller file:///Users/ryan/Desktop/Tutorial/bin-release/Tutorial.swf cannot access file:///Users/ryan/Desktop/Tutorial/bin-release/Tutorial.html."

      Anyone have any ideas or workarounds? This is driving me crazy.