xmlns:mx="http://www.adobe.com/2006/mxml" backgroundColor="white" creationComplete="init()" layout="vertical">
<mx:Script>
<![CDATA[
import flash.net.navigateToURL;
import mx.controls.Alert;
private const WEB_SITE:String = "http://www.baidu.com";
private function init():void
{
var str:String = "<a href='http://www.cppzone.com'><u><font color='#2754d5'>Request to use it!</font></u></a><br>"+
"<a href='event:http://www.cppzone.com'><u><font color='#2754d5'>Click to use it!</font></u></a>";
txt.htmlText+=str;
txt.addEventListener(TextEvent.LINK, doLink); //这里要监听link事件
}
private function doLink(evt:TextEvent):void
{
Alert.show(evt.text);
navigateToURL(new URLRequest(evt.text),'_self');
}
]]>
</mx:Script>
<mx:TextArea id="txt" width="600" height="400" fontSize="12"
htmlText="这是一个点击TextArea中的link到外部链接的例子,请点击下面的Click"/>
|