Skip to main content
Inspiring
June 30, 2009
Question

importToFlow with other configuration

  • June 30, 2009
  • 2 replies
  • 811 views

Due to another helpful reply in this forum I finally have a single line editable textfield working.

Problem now is that I still need to set configuration options. I dont really fully understand the framework as yet.

Here is my code.


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

textFlow.interactionManager = new EditManager();
textFlow.fontFamily = "Arial";
textFlow.fontSize = 20;
textFlow.lineBreak = "explicit";

textFlow.flowComposer.addController(new DisplayObjectContainerController(sprite,width,height));
textFlow.flowComposer.updateAllContainers();

However I need to also set some other options on my field.

Firstly I need to set the initial text of the field. Before I was doing this " var textFlow:TextFlow = TextFilter.importToFlow(text, TextFilter.PLAIN_TEXT_FORMAT);" but now I cant seem to figure out how to use the importToFlow along with the configuration.

Secondly. I need to restrict the field to only allow 50 characters (Due to database limits etc). How do I do this?

Are there some good demo resources that show code in practise in common situations we would have normaly used an old standard "TextField" for.

I've been reading the http://livedocs.adobe.com/labs/textlayout/ docs but there seem to be few simple examples for newbies to this area. Unless you sort of know where to go its all a bit confusing.

Thanks in advance.

This topic has been closed for replies.

2 replies

Inspiring
July 1, 2009

I was having trouble doing that due to the example that I copied from here

http://livedocs.adobe.com/labs/textlayout/flashx/textLayout/conversion/ImportExportConfiguration.html#textFlowConfiguration

My code was

var imExConfig:ImportExportConfiguration = new ImportExportConfiguration();

var config:Configuration = imExConfig.defaultConfiguration.textFlowConfiguration;
config.manageTabKey = false;
config.manageEnterKey = false;

var textFlow:TextFlow = TextFilter.importToFlow(text, TextFilter.PLAIN_TEXT_FORMAT, imExConfig);

but I was getting a "1119: Access of possibly undefined property defaultConfiguration through a reference with static type flashx.textLayout.conversion:ImportExportConfiguration." error... The docs say that defaultConfiguration is a valid property... so thats wierd.

Anyway afetr lots of messing around I got it to work this way

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

var imExConfig:ImportExportConfiguration = new ImportExportConfiguration();
imExConfig.textFlowConfiguration = config;

var textFlow:TextFlow = TextFilter.importToFlow(text, TextFilter.PLAIN_TEXT_FORMAT, imExConfig);

and that is now allowing me to use my config with the importToFlow.

Participating Frequently
June 30, 2009

Hi,

You can pass the configuration as the third parameter to TextFilter.importToFlow.

Abhishek

(Adobe Systems Inc.)