Skip to content

Instantly share code, notes, and snippets.

@bukzor
Created December 28, 2012 00:35
Show Gist options
  • Select an option

  • Save bukzor/4393506 to your computer and use it in GitHub Desktop.

Select an option

Save bukzor/4393506 to your computer and use it in GitHub Desktop.
Demo: TextField.text behaves differently when a stylesheet is set, even if the stylesheet is empty. The desired behavior is to get styled plain text (i.e. literal <i> tags displayed in output).
package {
import flash.text.TextField;
import flash.text.StyleSheet;
import flash.display.Sprite;
import flash.system.Capabilities;
public class HelloWorld extends Sprite {
private var textField:TextField;
public function HelloWorld( ) {
graphics.beginFill( 0xFFCC00 );
graphics.drawCircle( 40, 40, 40 );
trace("Hello, world!");
trace("isDebugger", Capabilities.isDebugger);
trace("isDebugBuild", (new Error().getStackTrace().search(/:[0-9]+]$/m) > -1));
this.textField = new TextField();
this.stage.addChild(this.textField);
var style:StyleSheet = new StyleSheet();
//style.parseCSS('* { color: #7e1e9c; size: 15px; font-weight: bold; font-family: arial; }')
this.textField.styleSheet = style;
this.textField.text = '<i>test</i>';
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment