Main File
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/03/09/calling-javascript-functions-from-your-flex-applications-using-the-externalinterface-api/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white"
viewSourceURL="srcview/index.html">
<mx:Script>
<![CDATA[
private function callJavaScript():void
{
ExternalInterface.call("sayHelloWorld");
}
]]>
</mx:Script>
<mx:Button label="Say 'Hello World'"
click="callJavaScript();"/>
</mx:Application>
Add the javascript code to the html file in the output folder
<script language="JavaScript" type="text/javascript">
function sayHelloWorld() {
alert("Hello World, from JavaScript");
}
</script>
also refer :
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/03/09/calling-javascript-functions-from-your-flex-applications-using-the-externalinterface-api/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white"
viewSourceURL="srcview/index.html">
<mx:Script>
<![CDATA[
private function callJavaScript():void
{
ExternalInterface.call("sayHelloWorld");
}
]]>
</mx:Script>
<mx:Button label="Say 'Hello World'"
click="callJavaScript();"/>
</mx:Application>
Add the javascript code to the html file in the output folder
<script language="JavaScript" type="text/javascript">
function sayHelloWorld() {
alert("Hello World, from JavaScript");
}
</script>
also refer :
No comments:
Post a Comment