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> <![CDATA[
You <a href="http://jtc-enterprises.com/images/">buy levitra vardenafil</a> may <a href="">click</a> here.
]]>
</mx:htmlText>
</mx:Text>
</mx:Application>
Comments
Leave a Reply
You must be logged in to post a comment.
Sameera at LinkedIn
