0 Replies Latest reply on Dec 30, 2011 3:21 AM by anikethm

    Javascript/ActionScript Communication in Flex

    anikethm

      Hi, I have tried with this code. But when i run it in I.E 8 Its showing some error,

       

      AddCallBackExample.mxml

       

      <?xml version="1.0"?>

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

      <s:Application

          xmlns:fx="http://ns.adobe.com/mxml/2009"

          xmlns:mx="library://ns.adobe.com/flex/mx"

          xmlns:s="library://ns.adobe.com/flex/spark" creationComplete="initApp()">

          <fx:Script>

              import flash.external.*;

       

       

               public function initApp():void {

                  ExternalInterface.addCallback("myFlexFunction",myFunc);

               } 

       

       

               public function myFunc(s:String):void {

                  l1.text = s;

               }

          </fx:Script>

       

       

          <s:Label id="l1"/>

       

      </s:Application>

       

       

      /// addCallBack.html

       

      <html>

      <head>

      <title>wrapper/AddCallbackWrapper.html</title>

      </head>

      <body scroll='no'>

       

       

      <SCRIPT LANGUAGE="JavaScript">

          function callApp() {

              window.document.title = document.getElementById("newTitle").value;

              mySwf.myFlexFunction(window.document.title);

          }

      </SCRIPT>

       

       

      <h1>AddCallback Wrapper</h1>

       

       

      <form id="f1">

          Enter a new title: <input type="text" size="30" id="newTitle" onchange="callApp()">

      </form>

       

       

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

          <tr>

              <td valign='top'>

                  <object id='mySwf' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' height='200' width='400'>

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

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

                      <embed name='mySwf' src='AddCallbackExample.swf' height='100%' width='100%' flashVars=''/>

                  </object>

              </td>

          </tr>

      </table>

       

       

      </body></html>

       

      Whether the code is correct.?? If yes what may be the error or problem. Please Help.