Skip to main content
Participant
October 20, 2012
Question

Append TextFlow to text area

  • October 20, 2012
  • 3 replies
  • 1403 views

Hi,

I'm need a text area that supports html text. I was wondering how I could append a TextFlow to the content of the text area, without parsing its entire content.

I've tried somthing like this:

tArea.textFlow.addChild(TextConverter.importToFlow(currentText, TextConverter.TEXT_FIELD_HTML_FORMAT));

but it won't work.

Do you have any workarounds for this?

Thanks,

Danut

This topic has been closed for replies.

3 replies

Legend
October 25, 2012

Hi,

I'm looking into something similar. According to the docs, TextArea.textFlow is only in the Spark theme and that isn't mobile...

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/spark/components/TextArea.html

Workarounds depend on what you want it for...

A fairly painless way to simply _display_ html is to use StageWebView.loadString(); method. Actually, that could offer significantly better results than TextArea.

For editing, I guess you're getting ready to face a lot of pain by hand-coding something based on TextField with manually setting the TextField.htmlText property... Won't be fun on a mobile.

G

October 25, 2012

Hello,

You may use something like this, as a workaround:

import spark.components.supportClasses.StyleableTextField;

StyleableTextField(yourTextArea.textDisplay).htmlText = "<font color='#AAAAAA'>example</font>";

Where yourTextArea is the id of your component.

But as far as I know, it can not be used with StageTextArea skin, i.e. you have to use a styleName for your TextArea component :

.textArea {

    skinClass: ClassReference("spark.skins.mobile.TextAreaSkin");

}

By default, TextArea components use "spark.skins.mobile.StageTextAreaSkin" skin class.

Nils

Legend
October 26, 2012

That's a nice shortcut! I like it.

Yes, you are correct. StageText doesn't support html and base mobile skin uses StyleableStageText where TextAreaSkin uses StyleableTextField.

That said, you've still only _displayed_ the HTML and there are a lot of limitations on what a textfield can and can't do. If display is all you need, I still think StageWebView will be better as you can do everything you could with htmlText _and_ show unmodified real web content. Integration with flash can still be achieved by putting in handlers for LocationChangeEvent.LOCATION_CHANGE and LocationChangeEvent.LOCATION_CHANGING to intercept links using custom url schemes etc. Interestingly, LOCATION_CHANGING is only fired for navigation events in the StageWebView and not for server redirects, but LOCATION_CHANGE seems to fire whenever there is a change to location value.

Would be interested to see _ANY_ examples of rich text editing done via Adobe AIR Mobile! Let me know if you come across anything - I built one before I got into Flex and I remember it was a bit of a pain in the bottom... and then I found Flex and the rich text editor component in MX that did it all for me and more reliably... ho hum.

G