2 Replies Latest reply on May 26, 2010 12:32 AM by kiran7881

    A query regarding calling JavaScript from Flex

    kiran7881 Level 1

      The below is an example for calling JavaScript from Flex .

      <mx:Script>
      <?xml version="1.0" encoding="iso-8859-1"?>
      <mx:Application xmlns:mx="
      http://www.adobe.com/2006/mxml">
          <mx:Script>
              import flash.external.*;

              public function callWrapper():void {
                  var f:String = "changeDocumentTitle";
                  var m:String = ExternalInterface.call(f,"New Title");
                  trace(m);
              }
          </mx:Script>
          <mx:Button label="Change Document Title" click="callWrapper()"/>
      </mx:Application>On your HTML page, you define a function as you would any other JavaScript function. You can return a value, as the following example shows:

       

      <SCRIPT LANGUAGE="JavaScript">
          function changeDocumentTitle(a) {
              window.document.title=a;
              return "successful";
          }
      </SCRIPT>


      Here the Author mentions that

       

      "This feature requires that the embedded movie file have an id attribute. Without it, no call from your Flex application will succeed."

       

       

      Can anybody please let me know what does it mean ??

       

      Thanks in advance .