PDA

View Full Version : using CSS in dynamic text


rajeshambady
02-05-2006, 01:15 PM
hi,

Please tell me how to use CSS in dynamic text - which is loading from XML.
I used this but it is not working.

var MediaAccess = new TextField.StyleSheet();
MediaAccess.load("css/media.css");

MediaAccess.onLoad = function(loaded){
if(loaded){
_root.createTextField("info",4,100,50,200,30)
info.text="Style Sheet is working"
info.styleSheet=MediaAccess;
}else {
info.text="uh this is not working"
}
};

Scottae
02-05-2006, 04:32 PM
Given this is the style sheet:

.body {
color: #FF0000;
font-family: Century Gothic;
font-size: 16;

}

Change your AS to look like this:

var MediaAccess:TextField.StyleSheet = new TextField.StyleSheet ();
MediaAccess.load ("css/media.css");
MediaAccess.onLoad = function (loaded)
{
var info:TextField = _root.createTextField ("info", 4, 100, 50, 200, 30);
info.border = true;
info.html = true;
if (loaded)
{
info.styleSheet = MediaAccess;
info.htmlText = "<span class='body'>Style Sheet is working</span>";
}
else
{
info.text = "uh this is not working";
}
};