Jason,

Have you found a solution for this issue?  I can't seem to make this work
either, although I used to do this all the time in Flash.  

Thanks,

-tom

-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Jason
Sent: Thursday, August 03, 2006 10:15 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Transform XML with external CSS styleSheet via
htmlText

I am looking for a little help.  What was fairly easy to do in AS2 and
Flash 8 is proving to be very tricky in Flex 2 AS3.  What I want to do
is assign a stylesheet to a TextArea component and then add text via
htmlText.  The text is coming from XML.

In AS2/F8 I had a nice system were all my XML element names matched up
to a style name in an external CSS file.
styles.css SNIP
[CODE]
questions {
        display: block;
        margin-left: 30px;
}
question {
        color: #000000;
        font-family: Arial;
        font-size: 10;
        display: block;
}
options {
        display: block;
        margin-left: 30px;
}
option {
        color: #000000;
        font-family: Arial;
        font-size: 10;
        display: block;
}

[/CODE]

SNIP from XML file
[CODE]
<interaction id="506">
<questions>
<question>While the nurse is explaining ...</question>
</questions>
<options>
<option id="1">Anger</option>
<option id="2">Denial</option>
<option id="3">Anxiety</option>
<option id="4">Depression</option>
</options>
[/CODE]

I could just assign the htmlText of a text field to the XML node, the
XML element tags would be treated as HTML tags and the appropriate
styles would be applied.

I have read through dozens of posts in this forum about this exact
problem, most people are just trying to get <a> links to underline.  I
have not found any solutions that make sense to me.

The help entry for TextArea.styleSheet just points to the
flash.text.StyleSheet class.  That class has one example,
http://livedocs.macromedia.com/flex/2/langref/flash/text/StyleSheet.html#inc
ludeExamplesSummary
, but I have not had any luck in getting the Example to work.  I am
not exactly sure what to do with the code.  I have tried to build a
StyleSheet object in the <mx:Script> tag, and I have also tried to
make an class file that has a method that returns a StyleSheet.  The
"addChild(label);" line in the example does not seem to be like a
document.write as I thought it was.  I can't get that to output
anything to the screen.  The constructor of the Class is firing however.

I am controlling the styles of all my components with no problem from
an external CSS file with <mx:Style source="styles/main.css"/>.  I can
assign one specific style to a TextArea, but not an entire StyleSheet.
 <my:Style> does not accept an "id" attribute and there does not seem
to be any way to link that loaded CSS file to a TextArea.styleSheet
property.

I have read that AS 3 cannot currently load a CSS at runtime, that
sucks, but I am open to a work around even if it means having to
define all my styles in AS (ick).

Here is the big QUESTION:
How can I embed an external CSS StyleSheet into my SWF, give it an ID,
and assign it to a TextArea.styleSheet property at runtime?  

If that is not possible, how can I create a Class (Styles.as) that
will house all my styles and somehow return a flash.text.StyleSheet
object that I can assign to my TextArea.styleSheet property?

I seem to have exhausted the help file on this issue.  Thanks for any
insight you can give on this.  

--jason













--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links




Reply via email to