代码之家  ›  专栏  ›  技术社区  ›  wezzy

加速设置文本格式()

  •  0
  • wezzy  · 技术社区  · 16 年前

    我有一个文本,其中有一个很长的单词列表要突出显示,每个单词调用setTextFormat()需要很长时间。有什么办法可以加快这次行动?我尝试在DisplayObject的列表中使用一个没有实例化的TextField来绕过呈现阶段,但是我发现性能是一样的。有什么想法吗?

    3 回复  |  直到 16 年前
        1
  •  1
  •   ZackBeNimble    16 年前

    我强烈建议您看看文本布局框架处理富文本样式的新模式。

    实际上,TLF有一个TextFlow对象,它包含文本的模型,包括所有相关的特定于span的格式。这与文本显示的“视图”部分不同,后者将由单独的流生成器和EditManager管理(在您的可编辑文本的情况下)。

    因此,您可以在文本模型的宽条带上执行格式转换,并且只有在最后命令视图重新绘制自己。

        2
  •  1
  •   JTtheGeek    15 年前

    _objFlow.interactionManager = _objEditManager;
                        _objEditManager.beginCompositeOperation();
    
                        DocColoringUtils.SetRegionColor(_objFlow, iStart, iEnd, BackgroundColor.TRANSPARENT, 1);
    
                        var colRegions:Vector.<Region> = _objResourceMediator.GetCurrentResourceRegions();
                        var objEditingExcerpt:Excerpt = _objExcerptingMediator.EditingExcerpt;
    
                        if (_objExcerptingMediator.InEditMode == true && objEditingExcerpt != null)
                        {
                            DocColoringUtils.ColorizeForEditMode(_objFlow, iStart, iEnd, colRegions, objEditingExcerpt.StartIndex, objEditingExcerpt.EndIndex, _objExcerptingMediator.SearchMatchRegions);
                        }
                        else
                        {
                            DocColoringUtils.ColorizeForNonEditMode(_objFlow, iStart, iEnd, colRegions, _objExcerptingMediator.SearchMatchRegions);
                        }
                        _objEditManager.endCompositeOperation();
    
                        _objFlow.interactionManager = _objSelectionManager;
    

    最后,您应该只对可视范围内的内容加上颜色+/-300个字符。然后滚动重新着色当前可视区域。这适用于一些非常大的文档 http://www.Dedoose.com

        3
  •  0
  •   antpaw    16 年前

    如果它是一个htmlText并且你想突出显示的单词被放在标签中,比如 <strong> 你应该看看 StyleSheet 对象的样式 loading a css file 也可以指定如下样式:

    var style:StyleSheet = new StyleSheet();
    var strong:Object = new Object(); 
    strong.textDecoration = "underline";
    style.setStyle("strong", strong);