基于FLEX+WEB SERVICE的在线翻译
其中,WEB SERVICE用的wsdl="" 是自己借助GOOGLE的翻译JAVA版本的API发布的WEB SERVICE服务。
FLEX代码如下:
<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="" layout="absolute" width="657" height="440"><mx:Script> <![CDATA[ import mx.rpc.events.ResultEvent; internal function resultHandler(evt:ResultEvent):void{ result_txt.text = evt.result.toString(); } internal function doSearch(fromL:String,toL:String):void{ ws.translatedText(input_txt.text,fromL,toL); } ]]></mx:Script><mx:WebService id="ws" wsdl="" result="resultHandler(event)" showBusyCursor="true"></mx:WebService> <mx:Panel x="52" y="30" width="558" height="384" layout="absolute" title="在线翻译" id="body" fontSize="14"> <mx:Label x="10" y="10" text="原文:" fontWeight="bold"/> <mx:TextArea x="10" y="31" width="491" height="101" id="input_txt"/> <mx:TextArea x="10" y="187" width="491" height="101" id="result_txt" editable="false" /> <mx:HBox x="10" y="152" width="491" verticalAlign="middle" horizontalAlign="center"> <mx:Button label="英文->中文" click="doSearch(en,zh)"/> <mx:Button label="清空" click="input_txt.text=;result_txt.text="/> <mx:Button label="中文->英文" click="doSearch(zh,en)"/> </mx:HBox> <mx:Label x="205" y="306" text="数据来自:" width="82"/> <mx:LinkButton x="275" y="302" label="" fontWeight="normal" width="226" enabled="true" click="navigateToURL(new URLRequest(http://www.google.cn/language_tools?hl=zh-CN))"/></mx:Panel></mx:Application>
效果图:

说明:其实可以实现多种语言的翻译,这里没完善。