在flex3中将图像插入TLF时,我发现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);
答案 0 :(得分:1)
也许这个?
inlineGraphicElement.textDecoration = null;
inlineGraphicElement.alignmentBaseline = TextBaseline.ASCENT;
inlineGraphicElement.lineHeight = "100%";
答案 1 :(得分: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
}