Skip to main content
June 12, 2013
Question

Textformat html in TLFTextfield: negative Leading ignored.

  • June 12, 2013
  • 0 replies
  • 535 views

Hey there,

I want to convert some old TextData (flash 8, limited pseudo html markup) so that it can be used and displayed in TLFTextFields.

Everything looks good so far, but it seems negativ leading is ignored.

Lets take this example, 2 Lines of a very large header.

My approach so far, using the TextConverter util class: 

1) Import the old string into a TextFlow.

2) Export this TextFlow to a newer format string.

3) modify the resulting string. (change the leading mode for example)

4) Re-import the TextFlow and use it on a TLFTextField.

Example Code:

var markup:String = '<TEXTFORMAT LEADING="-50"><P ALIGN="LEFT"><FONT FACE="Myriad Pro Cond" SIZE="120" COLOR="#9DC8C6" LETTERSPACING="0" KERNING="0"><B>Im line one</B></FONT></P></TEXTFORMAT><TEXTFORMAT LEADING="-50"><P ALIGN="LEFT"><FONT FACE="Myriad Pro Cond" SIZE="120" COLOR="#9DC8C6" LETTERSPACING="0" KERNING="0"><B>...and im line two</B><FONT COLOR="#00CCCC"></FONT></FONT></P></TEXTFORMAT>';

(1)

var importedFlow:TextFlow = TextConverter.importToFlow(markup, TextConverter.TEXT_FIELD_HTML_FORMAT);

//importedFlow.flowComposer.addController(new ContainerController(this, 600, 400));

importedFlow.flowComposer.updateAllControllers();

(2)

var s:String = TextConverter.export(importedFlow, TextConverter.TEXT_LAYOUT_FORMAT, ConversionType.STRING_TYPE) as String;

(3) Example modify.

// s = s.split('approximateTextField').join('ascentDescentUp');

(4)

var reImportedFlow:TextFlow = TextConverter.importToFlow(s1, TextConverter.TEXT_LAYOUT_FORMAT);

reImportedFlow.flowComposer.updateAllControllers();

var tf:TLFTextField = new TLFTextField();

addChild(tf);

tf.width = 600;

tf.height = 400;

tf.border = true;

tf.multiline = true;

tf.textFlow = reImportedFlow;

The new lineheight is -50 (lineHeight instead of leading),positive values are accepted, but negative values are ignored.

Any ideas how to fix this ?

This topic has been closed for replies.