Skip to main content
Participant
November 29, 2007
Question

TextArea and CSS error

  • November 29, 2007
  • 1 reply
  • 298 views
Hello!
I have a problem with TextArea and CSS. When i'm trying to attach css to TextArea instance flash returns error:
Error: Error #2009: This method cannot be used on a text field with a style sheet.
at flash.text::TextField/setTextFormat()
at fl.controls::TextArea/fl.controls:TextArea::drawTextFormat()
at fl.controls::TextArea/fl.controls:TextArea::draw()
at fl.core::UIComponent/::callLaterDispatcher()
full code of package:
This topic has been closed for replies.

1 reply

January 24, 2008
I've been searching all over the web. This almost has to be a bug. But I found a workaround that isn't terrible.

label.textField.styleSheet = sheet;
label.textField.htmlText = "<body><p><span class='heading'>Hello </span><a href='event:'>World...</a></p><p>1</p><p>2</p></body>";
label.verticalScrollPolicy = ScrollPolicy.AUTO;

Basically you load the text and the css into the textField. I haven't gotten it to work in any other combination. Then you have to basically reset the scrollbar to check the content again. It's only one line of code and I spent about a day figuring this out so I hope it helps someone. And if anyone knows why this is the way it is I'd love to hear it.

Eric Snowden
http://www.ericpaulsnowden.com
February 19, 2008
Eric,
That works for you? It doesn't work for me. I continue to get the 2009 error code. Here's my version of your code:

import fl.controls.*;

var sheet:StyleSheet = new StyleSheet();
label.textField.styleSheet = sheet;
label.textField.htmlText = "<body><p><span class='heading'>Hello </span><a href='event:'>World...</a></p><p>1</p><p>2</p></body>";
label.verticalScrollPolicy = ScrollPolicy.AUTO;

Only change was two additional lines needed at the beginning. There is a TextArea component on the stage. I still get the error when I run it. Perhaps your actual code has something else not shown in your example?

David Salahi