开发者

A question about the performance of htmlText in TextField

开发者 https://www.devze.com 2022-12-23 22:01 出处:网络
I have got a performance problem about TextField.htmlText +=msg.And I know thatTextField.appendText(msg) works better than TextField.text +=msg.So I wonder if there\'s some method better than 开发者_运

I have got a performance problem about TextField.htmlText +=msg.And I know thatTextField.appendText(msg) works better than TextField.text +=msg.So I wonder if there's some method better than 开发者_运维技巧TextField.htmlText +=msg?Any help would be appreciated.

Regards

Spawn


I haven't benchmarked it, but what I normally do is this:

var str:String = "bla bla";

for(var i:int = 0; i < 10; i++){
    str += " foo";
}

myTextfield.htmlText = str;

However, it's likely not that much of a boost unless you're doing large amounts of text and/or iterations.


Concatenate your text in a variable before assigning it to the htmlText property of any control. Every time you change that property you are calling all the lifecycle display methods like commitProperties, measure, and updateDisplayList, all of which take time to render.

0

精彩评论

暂无评论...
验证码 换一张
取 消