开发者

Too much space at the top of image in TLF using Flex3

When insert an image into TLF in flex3, I found that im开发者_Go百科age in TLF is displayed in a square area. so there is some space at the top of the image. See the attached image for this problem.

Too much space at the top of image in TLF using Flex3

How to remove this space? I try the following method, But it doesn't work!

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);


Maybe this?

inlineGraphicElement.textDecoration = null;
inlineGraphicElement.alignmentBaseline = TextBaseline.ASCENT;
inlineGraphicElement.lineHeight = "100%";


The following code is useful if you create your textFlow from an HTML source. It will correct for every images in the textflow the display.

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
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜