It seems like this thread has morphed into something else. But if you're
looking to style an input text field with CSS, here's a working example...
Note that this is only en example... some things that are hardcoded should
not be... but it gets the point across. The getStyleSheet and
getDefaultStyleSheet methods are only there so you don't have to load a
stylesheet for the example to work.
class SomeUsefulTextMethods
{
public static function getStyleSheet(css:Object):TextField.StyleSheet {
var style:String = "";
var styleSheet:TextField.StyleSheet = new TextField.StyleSheet();
style += ".bold {font-family:" + css.font + ";font-size: " +
css.size + ";font-weight: bold;color: " + css.color + ";}";
style += ".plain {font-family: " + css.font + ";font-size: " +
css.size + ";font-weight: normal;color: " + css.color + ";}";
style += ".italic {font-family: " + css.font + ";font-size: " +
css.size + ";font-style: italic;font-weight: normal;}";
style += "a:link {color: " + css.hoverColor + ";text-decoration:
none;}";
style += "a:hover {color: " + css.hoverColor + ";text-decoration:
underline;}";
styleSheet.parseCSS(style);
return styleSheet;
}
public static function getDefaultStyleSheet():TextField.StyleSheet {
return getStyleSheet({font:"Verdana", size:11, color:"#000000",
hoverColor:"#0000FF"});
}
public static function getInputField(scope:MovieClip, name:String,
x:Number, y:Number, w:Number, h:Number):TextField {
var field:TextField = scope.createTextField(name,
scope.getNextHighestDepth(), x, y, w, h);
field.type = "input";
field.border = true;
var myStyleSheet:TextField.StyleSheet = getDefaultStyleSheet();
var styleObj:Object = myStyleSheet.getStyle(".bold");
var styleFormat:TextFormat = myStyleSheet.transform(styleObj);
field.setTextFormat(styleFormat);
field.setNewTextFormat(styleFormat);
return field;
}
}
/**
* in fla...
* var field:TextField = SomeUsefulTextMethods.getInputField(this,
"myField", 100, 100, 100, 100);
*/
Jim Kremens
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com