12 Replies Latest reply on Jan 4, 2012 10:29 PM by anikethm

    Security error:external Interface

    anikethm

      Hi, I m trying with ActionScript to Javascript Communication. When i run through command

      prompt using "adl" then i m able to get the output but when i run in I.E browser its showing

      Security Error:External Interface. Here is my code.

       

      When i click on send button in swf file which is embedded in html, it should

      call receiveComplexDataTypes() function in javascript which it is not calling and generating Security Error

       

       

      -DataTypeWrapper.html

       

      <html><head>

      <title>wrapper/DataTypeWrapper.html</title>

      </head>

      <body scroll='no'>

       

       

      <SCRIPT LANGUAGE="JavaScript">

          function receiveComplexDataTypes(o) {

              alert("Welcome " + o.fname + " " + o.lname + "!");

              return "successful";

          }

      </SCRIPT>

       

       

      <h1>Data Type Wrapper</h1>

       

       

      <table width='100%' height='100%' cellspacing='0' cellpadding='0'>

          <tr>

              <td valign='top'>

                  <object id='mySwf' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab' height='200' width='400' >

                      <param name='src' value='DataTypeSender.swf'/>

       

                      <param name='flashVars' value=''/>

                      <embed name='mySwf' src='DataTypeSender.swf' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' height='100%' width='100%' flashVars=''/>

                  </object>

                                    <input type="text" id="t1"/>

              </td>

          </tr>

      </table>

       

       

      </body></html>

       

      -DataTypeScript.as

       

      import flash.external.*;

       

           public function callWrapper():void {

              var s:String;

              if (ExternalInterface.available) {

                 var o:Object = new Object();

                 o.fname = "Nick";

                 o.lname = "Danger";

                 var wrapperFunction:String = "receiveComplexDataTypes";

                 s = ExternalInterface.call(wrapperFunction, o);

              } else {

                 s = "Wrapper not available";

              }

              trace(s);

           }

       

      -DataTypeSender.mxml

       

      <?xml version="1.0"?>

      <!-- wrapper/DataTypeSender.mxml -->

      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

        <mx:Script source="DataTypeScript.as"/>

       

        <mx:Button label="Send" click="callWrapper()"/>

        <mx:Label id="l1"/>

       

      </mx:Application>

       

      Please Help me to run this Simple app in Browser.