public static function getHtmlFont(info:String,isBracket:Boolean=false,color:String="#654896"):String
{
var str:String="";
var bracketLeft:String="";
var BracketRight:String="";
if(isBracket==true)
{
bracketLeft="【";
BracketRight="】";
}
return "<font color='"+color.toString()+"'>"+bracketLeft+info.toString()+BracketRight+"</font>";
}
public static function getHtmlLink(info:String,fontColor:String="#000000",fontSize:String="14px"):String
{
return "<font size='"+fontSize.toString()+"' color='"+fontColor.toString()+"'><a href='event:ClickLink'>"+info.toString()+"</a></color>";
}
demo:
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/01/26/listening-for-the-link-event-in-a-flex-label-control/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private function lbl_initialize():void {
lbl.addEventListener(TextEvent.LINK,lbl_link);
lbl.htmlText = "For more information on Flex, see <font size='14px' color='#a40000'><a href='event:goods'>操操</a><a href='event:goods223'>fuckfuck</a></color>"; }
private function lbl_link(event:TextEvent):void {
//Alert.show(event.toString(), event.text);
switch (event.text) {
case "goods":
var labels:Label= event.currentTarget as Label;
Alert.show(labels.id.toString());
break;
case "goods223":
var labels2:Label= event.currentTarget as Label;
Alert.show(labels2.id.toString());
break;
}
}
]]>
</mx:Script>
<mx:Label id="lbl"
selectable="true"
initialize="lbl_initialize();"
/>
</mx:Application>
{
var str:String="";
var bracketLeft:String="";
var BracketRight:String="";
if(isBracket==true)
{
bracketLeft="【";
BracketRight="】";
}
return "<font color='"+color.toString()+"'>"+bracketLeft+info.toString()+BracketRight+"</font>";
}
public static function getHtmlLink(info:String,fontColor:String="#000000",fontSize:String="14px"):String
{
return "<font size='"+fontSize.toString()+"' color='"+fontColor.toString()+"'><a href='event:ClickLink'>"+info.toString()+"</a></color>";
}
demo:
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/01/26/listening-for-the-link-event-in-a-flex-label-control/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private function lbl_initialize():void {
lbl.addEventListener(TextEvent.LINK,lbl_link);
lbl.htmlText = "For more information on Flex, see <font size='14px' color='#a40000'><a href='event:goods'>操操</a><a href='event:goods223'>fuckfuck</a></color>"; }
private function lbl_link(event:TextEvent):void {
//Alert.show(event.toString(), event.text);
switch (event.text) {
case "goods":
var labels:Label= event.currentTarget as Label;
Alert.show(labels.id.toString());
break;
case "goods223":
var labels2:Label= event.currentTarget as Label;
Alert.show(labels2.id.toString());
break;
}
}
]]>
</mx:Script>
<mx:Label id="lbl"
selectable="true"
initialize="lbl_initialize();"
/>
</mx:Application>