2016-06-09 6 views

Répondre

1

Utilisez la propriété htmlText.

1.Setting htmlText à AS3.

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

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

2.Création de htmlText au format MXML.

<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> 

Si vous souhaitez ouvrir le lien dans une nouvelle fenêtre, utilisez linkHandler comme ci-dessous.

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

C'est la bonne réponse. Si vous voulez faire quelque chose de fantaisiste, cependant, vous pouvez utiliser les [frontières de caractères] (http://stackoverflow.com/questions/19837705/character-boundaries-of-text-field-based-on-parent) pour créer du visible (ou invisible). Ceci est utile pour les applications à écran tactile dans mon expérience. –