0
votes

When I add a StyleSheet as the .styleSheet property to a TextField the text doesn't get drawn.
The problem might be that, when a StyleSheet is needed (I'm using it only to format htmlText links) I can't set a TextFormat. But surely that should just mean the text has NO TextFormat.
Here's the relevant code (I do declare and instantiate the TextField earlier in the code; when I DON'T add the StyleSheet that all works correctly so I'm fairly sure that's not the problem):

_linkStyling = new StyleSheet();
_linkStyling.parseCSS('a { color: #99CCFF; }');
_textField.htmlText = p_text; // this is the String parameter passed in to my Text Class
_textField.styleSheet = _linkStyling;  

Is there anything I'm doing wrong with this?

1

1 Answers

0
votes

I just tried the same code (with variables declaration and a fixed string) and works fine. Try to run this simple example, maybe some parameters you are adding for your _textField or your p_text variable are the key of your issue.

stage.color = 0x000000;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;

var p_text:String = '<a href="http://stackoverflow.com/questions/20679148/stylesheet-makes-my-textfield-text-vanish">test</a>';

var _linkStyling:StyleSheet = new StyleSheet();
_linkStyling.parseCSS('a { color: #99CCFF; }');

var _textField:TextField = new TextField();
_textField.autoSize = 'left';
addChild(_textField);

_textField.htmlText = p_text;
_textField.styleSheet = _linkStyling;