Call from JavaScript : JavaScript « Development « Flex






Call from JavaScript

         

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initApp()">
  <mx:Script>
  import flash.external.ExternalInterface;
  import mx.controls.Alert;
  public function initApp():void {
    ExternalInterface.addCallback("callFromJavascript",callFromJavascript);
  }
  public function callFromJavascript(s:String):void {
    Alert.show(s,"Flex Alert");
  }
  private function sendToJavaScript():void {
    ExternalInterface.call("getFromFlex","asdf"); 
  }
  </mx:Script>
  <mx:Button click="this.sendToJavaScript()" label="Send to Javascript" />
</mx:Application>

   
    
    
    
    
    
    
    
    
  








Related examples in the same category

1. block calls the JavaScript changeDocumentTitle() function in the enclosing wrapper by using the call() method<fx:Script> block calls the JavaScript changeDocumentTitle() function in the enclosing wrapper by using the call() method
2.If you pass an object, you can access the properties of that deserialized object in the JavaScriptIf you pass an object, you can access the properties of that deserialized object in the JavaScript
3.Is JavaScript method call ready
4.Send to JavaScript
5.Call JavaScript function to get the result
6.Call JavaScript with ExternalInterface
7.Call JavaScript method and pass in parametersCall JavaScript method and pass in parameters