2

在flex3中将图像插入TLF时,我发现TLF中的图像显示在一个正方形区域中。所以图像顶部有一些空间。有关此问题,请参见附图。

Flex3中TLF中图像顶部的空间过多

如何删除这个空间?我尝试了以下方法,但它不起作用!

var graphic_element:InlineGraphicElement = IEditManager(activeFlow.interactionManager).insertInlineGraphic(foreignElementUrl, width, height, "none");

graphic_element.paddingTop = 0;
graphic_element.paddingBottom = 0;
graphic_element.paddingRight = 0;
graphic_element.paddingLeft = 0; 
IEditManager(activeFlow.interactionManager).applyParagraphFormat(graphic_element);
4

2 回答 2

1

也许这个?

inlineGraphicElement.textDecoration = null;
inlineGraphicElement.alignmentBaseline = TextBaseline.ASCENT;
inlineGraphicElement.lineHeight = "100%";
于 2011-10-13T09:21:09.470 回答
0

如果您从 HTML 源创建 textFlow,则以下代码很有用。它将纠正显示文本流中的每个图像。

static private function _InlineGraphicElementCorrection(children:Array):void
{
    var numChildren:int = children.length;
    for (var i:int=0; i<numChildren; i++)
    {
        if( children[i].hasOwnProperty('mxmlChildren') )
            _InlineGraphicElementCorrection(children[i].mxmlChildren);
        if( !(children[i] is InlineGraphicElement) )
            continue;

        var graphicElement : InlineGraphicElement = children[i];
        graphicElement.textDecoration = null;
        graphicElement.alignmentBaseline = TextBaseline.ASCENT;
        graphicElement.lineHeight = "100%";
    }
}

static public function importHtmlToFlow(html:String):TextFlow
{
    var flow : TextFlow = TextConverter.importToFlow(html.replace(/[\r\n]/ig, ""), TextConverter.TEXT_FIELD_HTML_FORMAT);
    _InlineGraphicElementCorrection(flow.mxmlChildren);
    return flow
}
于 2013-09-18T13:57:40.000 回答