代号为3551的警告也许是我最喜欢的一条警告了,它告诉我们,使用appendText方法可以大幅度提高效率。

原文:

Warning: 3551: Appending text to a TextField using += is many times slower than using the TextField.appendText() method.

我这里做了一个测试:

var allFonts:Array = Font.enumerateFonts(true);
var d = new Date().getTime();
for (var i:Number=0;i<allFonts.length;i++)
{
    var _f:Font = allFonts[i] as Font;
    //a.text+=_f.fontName;
    a.appendText(_f.fontName);
}
trace(new Date().getTime() - d);

更改将注释符号,得到的结果是,使用+=需要花费700多毫秒,而使用appendText方法,则把时间消耗控制在了100毫秒之内。

Still looking for something?

: http://as3blog.com/as3/use-appendtext-method-instead-of-simply-add-the-string/

Post a comment now » Sorry, the comments are closed.

No comments yet.

Sorry, the comment form is closed at this time.