1 Reply Latest reply on Feb 16, 2010 7:26 AM by Gregory Lafrance

    External Interface Question - Javascript to Actionscript

    George Donn Level 1


      I need this action script always running  during the whole life of the application - but if do not put it into a function I get an error that says "ReceovedFromJavaSript" is an unrecognized parameter - but my function is declared.

       

      But if I put the code (bold and italics) in a function it compiles but there is no way that javasript can reach it unless I trigger some event in the application to get that function rolling.

       

      thanks

      <fx:Script>
      <![CDATA[

             if (ExternalInterface.available) {
                      try {
                          ExternalInterface.addCallback("sendToActionScript", receivedFromJavaScript);   
                          }
                      } catch (error:SecurityError) {
                          Alert.show("A SecurityError occurred: " + error.message + "\n");
                      } catch (error:Error) {
                         
      Alert.show("An Error occurred: " + error.message + "\n");
                      }
                  } else {
                    
      Alert.show("External interface is not available for this container.");
                  }
              }


              private function receivedFromJavaScript(value:String):void {
                  Alert.show("JavaScript says: " + value + "\n");
              }

      ]]>
      <fx:Script>