2011-08-29 52 views
2

将图像插入到flex3的TLF中时,我发现TLF中的图像显示在正方形区域中。所以图像顶部有一些空间。请参阅附件图像了解此问题。使用Flex3的TLF中图像顶部的空间太多

too much space at the top of image in TLF in Flex3

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

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

回答

1

也许这样?如果从HTML源创建的textFlow

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

谢谢,最后的声明是关键。 – zhongshu

0

下面的代码是非常有用的。它会校正文本流中显示的每个图像。

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 
}