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; 把这个注释就好了...

  • 相关阅读:
    Lc5413_重新排列句子中的单词
    Lc5412._在既定时间做作业的学生人数
    Lc520_检测大写字母
    threadPoolExecutor的参数和拒绝策略
    coutdownlatch的使用
    volatile的个人理解
    Lc292_Nim 游戏
    Lc136_只出现一次的数字
    lc88_合并两个有序数组
    jdk源码_String(1)
  • 原文地址:https://www.cnblogs.com/flying_bat/p/3512701.html
Copyright © 2011-2022 走看看