flex 嵌入html

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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值