Skip to content

Instantly share code, notes, and snippets.

@girasquid
Created February 13, 2014 01:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save girasquid/8967802 to your computer and use it in GitHub Desktop.
Save girasquid/8967802 to your computer and use it in GitHub Desktop.
package text {
import flash.text.TextFormat;
public class SimpleFormat extends TextFormat {
public function SimpleFormat(options:Object):void {
for(var k:Object in options) {
if(this.hasOwnProperty(k)) {
this[k] = options[k];
}
}
}
}
}
@girasquid
Copy link
Author

This makes formatting your text a one-liner that you can use keyword arguments for.

Example:

var myField:TextField = new TextField();
myField.text = "some text";
myField.setTextFormat(new SimpleFormat({font: "Helvetica", size: 90, align: "center"}))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment