Return to Snippet

Revision: 16726
at August 13, 2009 12:02 by adamcoulombe


Initial Code
///////put this somewhere with your other functions//////
TextField.prototype.applyStyles=function(styles){
	fmt = new TextFormat();
	for (var key:String in styles){
		fmt[key]=styles[key];
	}
	this.setTextFormat(fmt);
}



////////pass in an object with all the styles you want
myTextField.applyStyles({color:"0xFFFFFF",letterSpacing:-2,bold:true,size:18});








/* here's some other styles (flash8)

myTextField2.applyStyles({
align:"center",
blockIndent:10, //indents the text block 10pt
bullet:true;
font:"Gill Sans",
indent:"3", //indents first character 3pt
italic:true,
kerning:true, //kerning enabled
leading:15, //15 pixels (line spacing)
leftMargin: 10, //10 point left margin
leftMargin: 10, //10 point right margin
underline:true,
color:"0xFFFFFF",
letterSpacing:-2,
bold:true,
size:18
});

*/

Initial URL

                                

Initial Description

                                

Initial Title
Easy  way  to Apply Styles to Text fields in Actionscript 2

Initial Tags
actionscript, flash

Initial Language
ActionScript