0 Replies Latest reply on Aug 9, 2010 5:25 AM by irockska

    Need to pass variable value from javascript to action script


      Hi everyone


      I am really stuck here. i have a swf file called text.swf which has two textfield by instance name name_txt which is input text field and anther dynamic textfield called return_txt. and a button . when the button is clicked it sends the text from name_txt to javascript. i am using actionscript 3, and in html file after embedding this file using swfobject, i can pass value from flash to javascript and there is no problem with it, but when i try to call a method in action script and set variable return_txt's text to something its not working, here is my code


      //actionscript code



      import flash.external.ExternalInterface;
      import flash.external.*;


      ExternalInterface.addCallback("onChange",onChange );


      function handler(evt:MouseEvent):void //this works perfectly
      //   trace("in event");   
      ExternalInterface.call("general_JS_call", name_txt.text);


      function onChange( str:String ){ //need to callt his method from js
        return_txt.text = str;
           // the return function


      //java script code



      <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">


      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />


      var me;
      function getID( swfID ){
           if(navigator.appName.indexOf("Microsoft") != -1){
                me = window[swfID];
               me = document.getElementById(swfID);



      function js_to_as( str ){
           me.onChange(str); //this is not working


      function general_JS_call( str ){
           //  val.text = str;
           me.onChange( prompt(str) );
      <body onLoad='getID("jsw");'>


      <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="400" height="300" id="jsw" >
      <param name="jsw" value="text.swf" >
      <param name="allowScriptAccess" value="always" />


      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="text.swf" width="400" height="300">
      <a href="http://www.adobe.com/go/getflashplayer">
      <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player">
      <!--[if !IE]>-->


      <!--  < <EMBED src="text.swf" quality=high bgcolor=#000000  WIDTH=400 HEIGHT=300 NAME=swf
          TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">
         <input type="button" value="Pass to AS" onClick="js_to_as('Test value');"></input>