flex actionscript 与javascirpt相互调用

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600">
	<mx:Script>
		<![CDATA[
			import flash.external.*;
			import mx.controls.Alert;
			public function asFunction():String{
				Alert.show("beCall");
				return "我是flex,我被调用";
			}
			public function beClick():void {
				ExternalInterface.addCallback("JavaScript中被调用的function",asFunction);
				ExternalInterface.call("eval",  "var jsvar="+Application.application.id+".JavaScript中被调用的function(); alert(jsvar); ");
			}
			
		]]>
	</mx:Script>
	<mx:Button id="aa" x="240" y="216" label="sssss" click="beClick()"/>
</mx:Application>
 

 

你可能感兴趣的:(JavaScript,html,Flex,相互调用)