Flex中如何给一个按钮添加链接,点击链接打开一个网页呢?
可以用 navigateToURL 或者 htmlText 实现,请看下面的例子
复制代码 代码如下:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initApp()"
layout="absolute" width="278" height="244">
<mx:script>
<![CDATA[
internal function initApp():void{
var str:String = "<a target='_blank' href='http://www.idceye.cn/'>草山狐随笔</a>";link.htmlText = str;
}
internal function openUrl():void{
navigateToURL(new URLRequest("http://www.idceye.cn/"), "_blank");
}]]>
</mx:script>
<mx:Button x="72" y="117" label="草山狐随笔" fontSize="13" id="link2" click="openUrl()"/>
<mx:Text id="link" text="idceye" x="72" y="47" fontSize="13"/>
</mx:Application>
可以用 navigateToURL 或者 htmlText 实现,请看下面的例子
复制代码 代码如下:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initApp()"
layout="absolute" width="278" height="244">
<mx:script>
<![CDATA[
internal function initApp():void{
var str:String = "<a target='_blank' href='http://www.idceye.cn/'>草山狐随笔</a>";link.htmlText = str;
}
internal function openUrl():void{
navigateToURL(new URLRequest("http://www.idceye.cn/"), "_blank");
}]]>
</mx:script>
<mx:Button x="72" y="117" label="草山狐随笔" fontSize="13" id="link2" click="openUrl()"/>
<mx:Text id="link" text="idceye" x="72" y="47" fontSize="13"/>
</mx:Application>
本文章来源于网络,作者是:,由代码部落进行采编,如涉及侵权请联系删除!转载请注明出处:https://daimabuluo.cc/flex/1311.html