Skip to main content
AdrianParr
Known Participant
Dec 23, 2009 4:26 PM UTC
Answered

Prevent multiline in TLF?

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 is closed to new replies. Start a new post to keep the conversation going.
robin_briggsCorrect answer
Adobe Employee
Dec 23, 2009 8:57 PM UTC

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

9 replies

AdrianParr
Known Participant
Jan 6, 2010 2:27 PM UTC

The key part is ...

var config:Configuration = new Configuration();

config.manageEnterKey = false;

var textFlow:TextFlow = new TextFlow(config)

Translate
AdrianParr
Known Participant
Jan 7, 2010 11:25 AM UTC

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;

Translate
A_Shiyaz
Known Participant
Feb 2, 2010 11:54 AM UTC

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

Translate
Adobe Employee
Dec 23, 2009 5:46 PM UTC

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

Translate
AdrianParr
Known Participant
Dec 23, 2009 6:24 PM UTC

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.

Translate
robin_briggsCorrect answer
Adobe Employee
Dec 23, 2009 8:57 PM UTC

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

Translate