2016-06-09 73 views

回答

1

使用htmlText属性。

1.在AS3上设置htmlText。

linkable.htmlText = "Register your phone number <a href='http://www.adobe.com'>Register Now</a>"; 

<mx:Label id="linkable" selectable="true"/> 

2.在MXML中设置htmlText。

<mx:Label id="linkable" selectable="true"> 
    <mx:htmlText> 
     <![CDATA[Register your phone number <a href='http://www.adobe.com'>Register Now</a>]]> 
    </mx:htmlText> 
</mx:Label> 

如果要在新窗口中打开链接,请使用linkHandler,如下所示。

public function linkHandler(event:TextEvent):void { 
    // Open the link in a new window. 
    navigateToURL(new URLRequest(event.text), '_blank') 
} 

<mx:Label id="linkable" selectable="true" link="linkHandler(event)"> 
    <mx:htmlText> 
     <![CDATA[Register your phone number <a href='event:http://www.adobe.com'>Register Now</a>]]> 
    </mx:htmlText> 
</mx:Label> 
+0

这是正确的答案。如果你想做一些奇特的事情,你可以使用[字符边界](http://stackoverflow.com/questions/19837705/character-boundaries-of-text-field-based-on-parent)来创建可见的(或不可见)按钮。根据我的经验,这对触摸屏应用非常有用。 –