zoukankan      html  css  js  c++  java
  • 关于RichTextField2.0表情显示错乱的问题!

    flex4.5和4.6在textField.getCharBoundaries()这个方法的返回结果上是不一样的。
    getCharBoundaries()方法只会返回被渲染出来的文字的边框信息,也就是说,如果文本框大小比真正的文本大小要小,那么你想要打印出没有显示的文字的边框信息是不可能的!
    在4.5中,打印出的边框信息是相对于textfield的textHeight属性,而4.6打印出的边框信息是相对于textfield的height属性。这就造成了richtextfield表情显示上的混乱!

    解决方法:

    private function renderSprite(sprite:DisplayObject, index:int):void
                       
                var rect:Rectangle = textRenderer.getCharBoundaries(index);    
                if (rect != null)
                {
                    sprite.x = (rect.x + (rect.width - sprite.width) * 0.5 + 0.5) >> 0;
                    var y:Number = (rect.height - sprite.height) * 0.5;
                    var lineMetrics:TextLineMetrics = textRenderer.getLineMetrics(textRenderer.getLineIndexOfChar(index));
                    //make sure the sprite's y is not smaller than the ascent of line metrics
                    if (y + sprite.height < lineMetrics.ascent) y = lineMetrics.ascent - sprite.height;
                    sprite.y = (rect.y + y + 0.5) >> 0;
                    //flex sdk 4.6添加,否则有显示bug
                    sprite.y += -_spriteContainer.y;

                    _spriteContainer.addChild(sprite);
                }
            }

    解决方法二: 封装包里的 SpriteRenderer类 把_spriteContainer.y = -textRenderer.scrollHeight; 把这个注释就好了...

  • 相关阅读:
    CF432D Prefixes and Suffixes
    CF126B Password
    如何实现输入历史记录功能
    python工作中总结
    今 天看到我十年前的一篇技术文章,想到不知不觉学编程十多年了,,
    现在互联网好多bug 想到都烦
    【图论】割点
    【DP】【P1941】【NOIP2014D1T3】飞扬的小鸟
    【线段树】【P3740】 [HAOI2014]贴海报
    【单调队列】【P1714】 切蛋糕
  • 原文地址:https://www.cnblogs.com/flying_bat/p/3512701.html
Copyright © 2011-2022 走看看