Skip to main content
Inspiring
Jun 30, 2009 4:44 AM UTC
Question

importToFlow with other configuration

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 is closed to new replies. Start a new post to keep the conversation going.

2 replies

Inspiring
Jul 1, 2009 12:03 AM UTC

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.

Translate
Participating Frequently
Jun 30, 2009 9:32 AM UTC

Hi,

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

Abhishek

(Adobe Systems Inc.)

Translate