首先mxml中有一个名为textArea的TextArea组件。

现在要在里面加入一段文字和一个文字链接。

 

代码如下:

private var s:String="这是一个";                             //文字部分

private var url:String="www.google.cn";                 //超链接的地址

public function text()
{
          textArea.htmlText = s+ "<a href= 'event:"+url+"' ><u><font   color='#2754d5'>谷歌首页</font></u></a>";                  //往textArea里面加入文字和超链接
          textArea.addEventListener(TextEvent.LINK,linkclick);//给超链接加上点击事件
}
private function linkclick(event:TextEvent):void
{
              navigateToURL(new URLRequest(event.text));      //转到www.google.cn
}

  

 

 

相关文章:

  • 2022-12-23
  • 2021-09-30
  • 2021-06-23
  • 2021-12-23
  • 2021-10-01
  • 2021-09-28
  • 2022-12-23
  • 2022-02-14
猜你喜欢
  • 2021-12-23
  • 2021-10-13
  • 2021-11-23
  • 2021-12-23
  • 2022-12-23
  • 2021-08-21
  • 2021-09-19
相关资源
相似解决方案