备忘
index.template.html
......
<title></title>
<script language="javascript">
function toSWF(value){
//alert(value);
getMovie("swf_HTML").fromJS(value);
//document.forms["testForm"].input.value="";
}
function fromSWF(value){
document.forms["testForm"].output.value += "From SWF " + value + "\n";
}
</script>
......
<form name="testForm">
<input type="text" name="input" value=""/>
<input type="button" value="ToSWF" onClick="toSWF(document.testForm.input.value)"/>
<textarea name="output" readonly="readonly" cols="60" rows="20"></textarea>
</form>
</body>
</html>
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="270" height="226"
creationComplete="crea()">
<mx:Canvas borderStyle="solid">
<mx:Text id="txt" x="10" y="10" width="252" height="147" text="testttt"/>
</mx:Canvas>
<mx:Button label="toJS" x="10" y="195" click="toJS()"/>
<mx:TextInput id="txtInput" x="10" y="165"/>
<mx:Script>
<![CDATA[
private function crea():void{
ExternalInterface.addCallback("fromJS",fromJS);
}
private function toJS():void{
ExternalInterface.call("fromSWF",txtInput.text);
}
public function fromJS(value:String):void{
txt.text += "from JS " + value + "\n";
}
]]>
</mx:Script>
</mx:Application>