1 Reply Latest reply on Oct 5, 2008 11:36 PM by _Sohaib_

    Call Actionscript function from Javascript

    lordsiris66
      Can anyone show me a simple example of calling an actionscript function from within javascript? Everything I have found searching online refers to using the ExternalInterface but I was sure I also read that Adobe Air does not support it. I am currently using htmlloader to load a html page containing javascript into an <mx:HTML>. But I cant seem to touch the actionscript functions from within javascript. I am specifically trying to work with the FCKeditor that I have integrated so if anyone has any examples other methods of integrating the editor I would love to see them as well.

      Thanks!
        • 1. Re: Call Actionscript function from Javascript
          _Sohaib_ Level 1
          Let's assume u have embeded swf object named "flashObj"

          <embed src="MYSWF.swf" quality="high"
          width="100%" height="100%" name="flashObj"
          play="true"
          loop="false"
          quality="high"
          allowScriptAccess="sameDomain"
          type="application/x-shockwave-flash"
          pluginspage=" http://www.adobe.com/go/getflashplayer">
          </embed>


          On each time onblur is called it invoke AS function myActionScriptFn

          window.onblur = function() {
          if(flashObj != null){
          flashObj.myActionScriptFn(navigator.appName);
          }
          };



          You need to add a listener in Action Script code

          ExternalInterface.addCallback("myActionScriptFn", myActionScriptFn);

          public function myActionScriptFn(appName:String):void
          {
          // Any code here
          }





          Regards