`

air与js互相调用

    博客分类:
  • air
阅读更多
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
	 layout="absolute" creationComplete="init()">
	<mx:Script>
		<![CDATA[
			import mx.controls.Alert;
			import flash.external.ExternalInterface;
			private function init():void{

				this.fck.domWindow.handle=change;//注册函数.js中调用handle函数时,会调用chanage方法
			}
			private function change(str:String):void{
	
				text.text=str;
			}
			private function textInputChange():void{
				this.fck.htmlLoader.window.test(text.text);//调用js中test方法
			}
		]]>
	</mx:Script>
	<mx:HBox>
		
		<mx:TextInput id="text" change="textInputChange()">
			
		</mx:TextInput>
		<mx:TextInput>
			
		</mx:TextInput>
		<mx:HTML location="airandJs.html" id="fck">
			
		</mx:HTML>
	</mx:HBox>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script language="javascript">
	//onChanage();
	function onChange(){
	try{
		var text=document.getElementById("text").value;
		
		handle(text);//调用air中的As方法
	}catch(e){
		alert(e);
	}
	}
      //air调用
	function test(str){
		
		document.getElementById("text").value=str;
	}
	
	 function thisMovie(movieName) {
         if (navigator.appName.indexOf("Microsoft") != -1) {
             return window[movieName];
         } else {
             return document[movieName];
         }
     }

	
</script>
</head>

<body>
	<input type="text" id="text"  value="str" />
    <input type="button" value="提交" onclick="onChange()"/>
</body>
</html>
 </mx:WindowedApplication>
 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics