Groups | Blog | Home
all groups > flash actionscript > february 2007 >

flash actionscript : Using stylesheets with an html enabled textArea


willrose
2/27/2007 8:11:49 PM
Hi guys,

I'm trying to use stylesheets with an html enabled textArea. My goal is to be
able to use something like this (see Fig 1 below):

What I am currently using is listed in Fig 2. This works as long as I wrap my
text in Fig 1 in paragraph tags.

I would like to be able to use something like Fig 3. The problem is I don't
know how to use a global selector in the setStyle function. Does such a thing
exist? If I remember correctly, CSS usually uses an '*' to denote that a style
should be applied globally, but it does not seem to be working here. Any help
would be appreciated, thanks!




/****** Fig 1 ******/
taContent.text = "This is a sentence containing <b>bold</b> text";

/****** Fig 2 ******/
var cssTa:TextField.StyleSheet = new TextField.StyleSheet();
cssTa.setStyle("p", {fontFamily:'Arial,Helvetica,sans-serif', fontSize:'11pt',
color:'#000000'});
cssTa.setStyle("h1", {fontFamily:'Arial,Helvetica,sans-serif',
fontSize:'12pt', fontWeight:'bold', color:'#000000'});
taContent.html = true;
taContent.styleSheet = cssTa;

/****** Fig 3 ******/
var cssTa:TextField.StyleSheet = new TextField.StyleSheet();
cssTa.setStyle("*", {fontFamily:'Arial,Helvetica,sans-serif', fontSize:'11pt',
color:'#000000'});
cssTa.setStyle("h1", {fontSize:'12pt', fontWeight:'bold'});
taContent.html = true;
taContent.styleSheet = cssTa;
SymTsb
2/27/2007 10:34:52 PM
Remember that flash only supports a limited number of CSS1 style techniques. *
is not one of them.

a work around though is to create an actual html file with body tags and load
that in. you don't need the html, head etc. just the stuff from body on down.
replace the * with body in your css and you should be ok.

Granted, this isn't a perfect fix or the way we'd all like it to be. I'd love
to see * implemented in Flash 9 and AS3. Unfortunately, encapsulating the
entire document in a set of body tags is the only solution i've found myself.
AddThis Social Bookmark Button