Skip to main content
AdrianParr
Known Participant
December 23, 2009
Answered

Prevent multiline in TLF?

  • December 23, 2009
  • 2 replies
  • 2420 views

How do you prevent carriage returns when using the TLF?

With the old TextField youi could just do multiline = false.

Is the an equivalent in the TLF?

Old style code below ...

var tf:TextField = new TextField();
tf.border = true;
tf.width = 100;
tf.height = 20;
tf.type = TextFieldType.INPUT;
tf.border = true;
tf.multiline = false;
tf.text = "Hello World";
addChild(tf);

Thanks in advance,

Adrian

This topic has been closed for replies.
Correct answer robin_briggs

You could look at the Flex OpenSource code for the multiline attribute in RichEditableText and see how they implemented it. You will probably wish to set the lineBreak attribute for the TextFlow to "explicit". Then you need to do something that will block new paragraphs from being created. The easiest thing might be to set the Configuration.manageEnterKey to false, which disables the enter key from being treated as a split paragraph request.

- robin

2 replies

AdrianParr
Known Participant
January 6, 2010

The key part is ...

var config:Configuration = new Configuration();

config.manageEnterKey = false;

var textFlow:TextFlow = new TextFlow(config)

AdrianParr
Known Participant
January 7, 2010

UPDATE: I've now got it working using Flash CS4 and the 'TextLayout.swc'. I've found that it is best not to use the (old - Nov '08) TextLayout Component for CS4, as it includes properties and methods that are no longer supported. The TLF language is in Beta and sunbject to change. For best results, just use the latest SWC available.

So, the updated code now looks like ...

import flashx.textLayout.container.*;
import flashx.textLayout.elements.*;
import flashx.textLayout.edit.*;

var config:Configuration = new Configuration();
config.manageEnterKey = false;

var textFlow:TextFlow = new TextFlow(config);

var para:ParagraphElement = new ParagraphElement();

var span:SpanElement = new SpanElement();
span.text = "Hello World";

para.addChild(span);
textFlow.addChild(para);

var cc:ContainerController = new ContainerController(this, 550, 400);
textFlow.flowComposer.addController(cc);
textFlow.flowComposer.updateAllControllers();

var em:EditManager = new EditManager();
textFlow.interactionManager = em;

A_Shiyaz
Known Participant
February 2, 2010

Hi Adrian,

Could you point to the link to the latest SWC please? I have three different sets and am using the outdated one, along with a link to the one from examples.

  1. The outdated one which comes with the TLF MXP http://labs.adobe.com/downloads/textlayout.html (textlayout_flashcomponent_p1_111808; the library timestamp says a date: 11.14.2008)
  2. The one which comes with the examples from TLF blog: http://blogs.adobe.com/tlf/examples/ (TLF_Examples_9.22.2009)
  3. And the one found at http://opensource.adobe.com/svn/opensource/flex/sdk/trunk/frameworks/libs/ (Trunk 13879 date stamp: 1.27.2010)

Which one are you using?

Regards,

Shiyaz

Adobe Employee
December 23, 2009

You can do this with the new spark components, I think. You can do the same thing with TLF directly, but there's a little more work to it. I'd suggest looking at the RichEditableText component, which does have a multiline property.

- robin

AdrianParr
Known Participant
December 23, 2009

Thanks Robin, but I need this for a project that already exists as a Flash CS4 project (not a Flex one). I've added the 'textLayout.swc' to the Library path and am creating a TextFlow instance as per your downloadable 'Hello World' example.So just using AS3.

robin_briggsCorrect answer
Adobe Employee
December 23, 2009

You could look at the Flex OpenSource code for the multiline attribute in RichEditableText and see how they implemented it. You will probably wish to set the lineBreak attribute for the TextFlow to "explicit". Then you need to do something that will block new paragraphs from being created. The easiest thing might be to set the Configuration.manageEnterKey to false, which disables the enter key from being treated as a split paragraph request.

- robin