<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" implements="mx.core.IToolTip"
width="140" height="40" fontSize="12"
xmlns:ns1="*" verticalScrollPolicy="off"
horizontalScrollPolicy="off" styleName="tips"
mouseEnabled="false" cornerRadius="0">
<mx:TextArea fontSize="12" backgroundColor="black" textAlign="left" borderColor="black" color="white" id="texAID" htmlText="{_htmlText}"
width="{taW}" height="{taH}" y="8" x="8"/>
<mx:Script>
<![CDATA[
import mx.events.IndexChangedEvent;
public function onCreate():void{
_htmlText = "<font>ssds</font><br/><font>sdsdsds</font>";
}
[Bindable]
public var _htmlText:String;
[Bindable]
public var taW:int;
[Bindable]
public var taH:int;
public function get text():String {
return _htmlText;
}
public function set text(value:String):void {
}
public function setDescription(desc:String,num:int):void
{
// texAID.htmlText = desc; [b]//一定要使用绑定,[/b]
var temp:String ="";
trace(desc.length);
for(var i:int=0;i<desc.length;){
temp += "<font>"
if((i+num)>desc.length){
temp += desc.substr(i,desc.length-i);
temp +="</font>";
i+=(desc.length-i);
}else{
temp += desc.substr(i,num);
temp +="</font>";
i+=num;
if(i!=desc.length){
temp +="<br>";
}
}
}
this.width = 13*num+10;
taW = 13*num;
this.height = 18*(Math.ceil(desc.length/num))+10;
taH = 18*(Math.ceil(desc.length/num));
_htmlText = temp;
}
public function setDescription2(tempS:Array,colors:Array,num:int):void
{
// texAID.htmlText = desc;
this.width=0;
this.height=0;
var flag:Boolean = false;
var temp:String ="";
for(var index:int=0;index<tempS.length;index++){
var desc:String = tempS[index];
trace(desc.length);
for(var i:int=0;i<desc.length;){
temp += "<font color='"+colors[index]+"'>"
if((i+num)>desc.length){
temp += desc.substr(i,desc.length-i);
temp +="</font>";
i+=(desc.length-i);
}else{
temp += desc.substr(i,num);
temp +="</font>";
i+=num;
if(i!=desc.length){
temp +="<br>";
}
}
}
if(index<(tempS.length-1)){
temp+="<br/>"
}
if(index<(tempS.length)){
this.height += 18*(Math.ceil(desc.length/num));
taH += 17*(Math.ceil(desc.length/num));
}
if(flag==false){
this.width = 13*num+10;
taW = 13*num;
flag = true;
}
}
this.height +=6;
_htmlText = temp;
}
]]>
</mx:Script>
</mx:Canvas>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" implements="mx.core.IToolTip"
width="140" height="40" fontSize="12"
xmlns:ns1="*" verticalScrollPolicy="off"
horizontalScrollPolicy="off" styleName="tips"
mouseEnabled="false" cornerRadius="0">
<mx:TextArea fontSize="12" backgroundColor="black" textAlign="left" borderColor="black" color="white" id="texAID" htmlText="{_htmlText}"
width="{taW}" height="{taH}" y="8" x="8"/>
<mx:Script>
<![CDATA[
import mx.events.IndexChangedEvent;
public function onCreate():void{
_htmlText = "<font>ssds</font><br/><font>sdsdsds</font>";
}
[Bindable]
public var _htmlText:String;
[Bindable]
public var taW:int;
[Bindable]
public var taH:int;
public function get text():String {
return _htmlText;
}
public function set text(value:String):void {
}
public function setDescription(desc:String,num:int):void
{
// texAID.htmlText = desc; [b]//一定要使用绑定,[/b]
var temp:String ="";
trace(desc.length);
for(var i:int=0;i<desc.length;){
temp += "<font>"
if((i+num)>desc.length){
temp += desc.substr(i,desc.length-i);
temp +="</font>";
i+=(desc.length-i);
}else{
temp += desc.substr(i,num);
temp +="</font>";
i+=num;
if(i!=desc.length){
temp +="<br>";
}
}
}
this.width = 13*num+10;
taW = 13*num;
this.height = 18*(Math.ceil(desc.length/num))+10;
taH = 18*(Math.ceil(desc.length/num));
_htmlText = temp;
}
public function setDescription2(tempS:Array,colors:Array,num:int):void
{
// texAID.htmlText = desc;
this.width=0;
this.height=0;
var flag:Boolean = false;
var temp:String ="";
for(var index:int=0;index<tempS.length;index++){
var desc:String = tempS[index];
trace(desc.length);
for(var i:int=0;i<desc.length;){
temp += "<font color='"+colors[index]+"'>"
if((i+num)>desc.length){
temp += desc.substr(i,desc.length-i);
temp +="</font>";
i+=(desc.length-i);
}else{
temp += desc.substr(i,num);
temp +="</font>";
i+=num;
if(i!=desc.length){
temp +="<br>";
}
}
}
if(index<(tempS.length-1)){
temp+="<br/>"
}
if(index<(tempS.length)){
this.height += 18*(Math.ceil(desc.length/num));
taH += 17*(Math.ceil(desc.length/num));
}
if(flag==false){
this.width = 13*num+10;
taW = 13*num;
flag = true;
}
}
this.height +=6;
_htmlText = temp;
}
]]>
</mx:Script>
</mx:Canvas>