Return to Snippet

Revision: 4223
at January 27, 2010 11:28 by chrisaiv


Updated Code
//Create an style that would simulate <h4> tags
var h4:Object = new Object();
h4.fontWeight = "bold";
h4.color = "#FF0000";
h4.fontSize = 30;
//Create a Style to simulate a:link tags
var a:Object = new Object();
a.color = "#00FF00";
a.fontSize = 25;
var aHover:Object = new Object();
aHover.fontSize = 25;
aHover.color = "#cccccc";

var style:StyleSheet = new StyleSheet();
style.setStyle("h4", h4);
style.setStyle("a", a);
style.setStyle("a:hover", aHover);

var tf:TextField = new TextField();
tf.x = 150;
tf.y = 150;
tf.width = 100;
tf.height = 100;
tf.styleSheet = style;
tf.htmlText = "<h4>library</h4>";
tf.htmlText += "<p><a href=\"event:http://www.usc.edu\" target=\"_blank\">science</a></p>";
addChild(tf);

Revision: 4222
at November 8, 2007 16:43 by chrisaiv


Initial Code
//Create an style that would simulate <h4> tags
var h4:Object = new Object();
h4.fontWeight = "bold";
h4.color = "#FF0000";
h4.fontSize = 30;
//Create a Style to simulate a:link tags
var a:Object = new Object();
a.color = "#00FF00";
a.fontSize = 25;
var aHover:Object = new Object();
aHover.fontSize = 25;
aHover.color = "cccccc";

var style:StyleSheet = new StyleSheet();
style.setStyle("h4", h4);
style.setStyle("a", a);
style.setStyle("a:hover", aHover);

var tf:TextField = new TextField();
tf.x = 150;
tf.y = 150;
tf.width = 100;
tf.height = 100;
tf.styleSheet = style;
tf.htmlText = "<h4>library</h4>";
tf.htmlText += "<p><a href=\"event:http://www.usc.edu\" target=\"_blank\">science</a></p>";
addChild(tf);

Initial URL
http://www.adobe.com/livedocs/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00000908.html

Initial Description
There's a way to add styles to text without using the traditional StyleSheet() object. I tend to think of this as a quick and dirty solution

Initial Title
AS3: Adding text styles to a TextField() using a new Object()

Initial Tags

                                

Initial Language
ActionScript 3