Relax Breath of Solution.Community tech blog of Sameera Thilakasiri - Consultant UI, UX, RWD Specialist/ Interactive Designer

Just I wanted.. Do you?…

HTML link in Flex – Listening for the link event in a Flex Label control

Posted on August 21, 2010 | No Comments

I’ve never found the need to have HTML links in Flex behave (and look) like their true HTML counterparts, but a student recently asked how she could get HTML links defined in a Text control to behave like regular HTML links.

<?xml   version="1.0" encoding="utf-8"?>
<mx:Application   xmlns:mx="http://www.adobe.com/2006/mxml"       layout="absolute">
<mx:Script>
<![CDATA[
       
import mx.core.mx_internal;
     
public function textHandler(e:Event):void
{
    var styleSheet:StyleSheet = new StyleSheet();
    styleSheet.setStyle("a:link",   { textDecoration: "underline",   color: "#30F" });
    e.currentTarget.mx_internal::styleSheet       = styleSheet;
}
     
]]>
</mx:Script> 
 
 
<mx:Text initialize="this.textHandler(event)">
      <mx:htmlText>
   <a href="http://marvabrooks.com/images/">buy viagra pill</a>         &lt;![CDATA[
        You <a href="http://jtc-enterprises.com/images/">buy levitra vardenafil</a>  may &lt;a href=&quot;&quot;&gt;click&lt;/a&gt;           here.
    ]]&gt;
        &lt;/mx:htmlText&gt;
&lt;/mx:Text&gt;
   
&lt;/mx:Application&gt;

Author
Sameera Thilakasiri By Sameera Thilakasiri
,is a front-end developer based in Colombo, is a blogger and a lifestyle photographer.
Follow him Twitter and Google+. Check out him.

Comments

Leave a Reply

You must be logged in to post a comment.