Question : AS3: Can you apply a style sheet to a textfiled in a movieclip?

I just asked a very similar question, but I'm trying now to attack the problem from a different view point. If I have a movieclip with text fields and I attach that movie to the stage - can I then add a style sheet format to the text field before adding the text? All the examples I've seen of how to use stylesheets in as3 start with creating the text field in the AS code. I want to apply my stylesheet info to a text field that is already created on the stage.

Answer : AS3: Can you apply a style sheet to a textfiled in a movieclip?

yes, here is the code to implement inline StyleSheet:


import flash.text.StyleSheet;

var myCSS = new StyleSheet();
var aHover:Object = new Object();
aHover.fontWeight = "bold";
aHover.textDecoration = "underline";
myCSS.setStyle("a:hover",aHover);
var aLink:Object = new Object();
aLink.fontWeight = "normal";
aLink.textDecoration = "none";
myCSS.setStyle("a:link",aLink);

// Assume TextField instance nameis myTxt;

myTxt.styleSheet = myCSS;
Random Solutions  
 
programming4us programming4us