1 Reply Latest reply on Dec 11, 2007 10:29 AM by NewbieToFlex

    Calling JavaScript function from Flex

    NewbieToFlex
      Hi all,

      I am trying to call a JavaScript function from my flex app. I know that you use ExternalInterface.call to call a JavaScript function from flex. I have read this article "Calling JavaScript methods from Flex applications". It seem's very simple, but for some reason it is not working. In my flex function I am doing the following:
      -----------------------------------------------------------------------
      var f:String = "changeDocumentTitle";
      var m:String = ExternalInterface.call(f,"New Title");
      trace(m);
      -----------------------------------------------------------------------

      And in the html wraper file I have the following code:

      --------------------------------------------------
      function changeDocumentTitle(a) {
      Alert('Testing');
      window.document.title=a;
      return "successful";
      }
      --------------------------------------------------

      In the above documentation it states the following as a requirement:
      "This feature requires that the embedded movie file have an id attribute. Without it, no call from your Flex application will succeed."

      I am not sure what this exactly mean's or the code in the html wraper mean's. But I see "id" in that file. I been trying to figure this out for the last two days. I read somewhere that allowScriptAccess must be either "always" or "sameDomain". It says "sameDomain" on my file. So I guess that is not an issue. Does anyone know anything else that could be wrong with this? Thank you very much.

      Sanch S.