<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Shared Know How &#187; CSS</title>
	<atom:link href="http://www.sharedknowhow.com/tag/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sharedknowhow.com</link>
	<description>Howto: fix, find, use, make &#38; do it guide</description>
	<lastBuildDate>Fri, 16 Apr 2010 09:41:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Fixed AS3 Flash TextArea &#8211; CSS incompatibility</title>
		<link>http://www.sharedknowhow.com/2008/07/fixed-flash-textarea-css-incompatibility/</link>
		<comments>http://www.sharedknowhow.com/2008/07/fixed-flash-textarea-css-incompatibility/#comments</comments>
		<pubDate>Tue, 08 Jul 2008 16:36:25 +0000</pubDate>
		<dc:creator>wytze</dc:creator>
				<category><![CDATA[flash]]></category>
		<category><![CDATA[actionscript3]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[class extends]]></category>
		<category><![CDATA[component]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[stylesheet]]></category>
		<category><![CDATA[text format]]></category>
		<category><![CDATA[TextArea]]></category>
		<category><![CDATA[TextField]]></category>

		<guid isPermaLink="false">http://www.sharedknowhow.com/?p=13</guid>
		<description><![CDATA[When working with flash components we often run into disadvantages. As with the TextArea class (fl.controls.TextArea) we encountered that it is not possible to use a CSS on its 'textField' property. Once again we thought to have the fast way to an end with components, but nothing of the sort.:'(
Since the 'styleSheet' property returns a [...]]]></description>
			<content:encoded><![CDATA[<p>When working with flash components we often run into disadvantages. As with the TextArea class (fl.controls.TextArea) we encountered that it is not possible to use a CSS on its 'textField' property. Once again we thought to have the fast way to an end with components, but nothing of the sort.:'(</p>
<p>Since the 'styleSheet' property returns a standard TextField instance it struck us as weird that setting its 'styleSheet' property didn't work. The TextArea class was trying to set textFormat which fails after setting the stylesheet of the textfield.</p>
<p><strong>Error message:</strong></p>
<div style="margin: 0pt; padding: 0pt; white-space: pre; display: inline;">Error: Error #2009: This method cannot be used on a text field with a style sheet.</div>
<div style="margin: 0pt; padding: 0pt; white-space: pre; display: inline;">at flash.text::TextField/setTextFormat()</div>
<div style="margin: 0pt; padding: 0pt; white-space: pre; display: inline;">at fl.controls::TextArea/drawTextFormat()</div>
<div style="margin: 0pt; padding: 0pt; white-space: pre; display: inline;">at fl.controls::TextArea/draw()</div>
<div style="margin: 0pt; padding: 0pt; white-space: pre; display: inline;">at fl.core::UIComponent/callLaterDispatcher()</div>
<p>This pointed us to the 'drawTextFormat()' function in the TextArea class. After taking a look we figured out what to do.</p>
<p>The problem turned out to be that every time you add text to your textarea the class tries to add a designated, or default flash-textFormat to the textfield. Adding Flash TextFormat objects to textfields conflicts with stylesheets. Our solutions was relatively simple: a small class extends of the textArea class.</p>
<p>Click continue for the fixing source<br />
<span id="more-13"></span></p>
<pre class="actionscript">    <span style="color: #0066CC;">import</span> fl.<span style="color: #006600;">controls</span>.<span style="color: #006600;">TextArea</span>;
&nbsp;
    <span style="color: #808080; font-style: italic;">/**
    * @makes it possible to do textArea.textField.styleSheet
    * @author Tim de Jong - Dooping VOF 2008 - tim -AT- dooping.nl
    * @version 001
    */</span>
&nbsp;
    <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> doopingTextArea <span style="color: #0066CC;">extends</span> TextArea
    <span style="color: #66cc66;">&#123;</span>
        <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> doopingTextArea<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#123;</span>
            <span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        override protected <span style="color: #000000; font-weight: bold;">function</span> drawTextFormat<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
            <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>!<span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">textField</span>.<span style="color: #006600;">styleSheet</span><span style="color: #66cc66;">&#41;</span> <span style="color: #0066CC;">super</span>.<span style="color: #006600;">drawTextFormat</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
                setEmbedFont<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
                <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>_html<span style="color: #66cc66;">&#41;</span> <span style="color: #0066CC;">textField</span>.<span style="color: #0066CC;">htmlText</span> = _savedHTML;
            <span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #66cc66;">&#125;</span></pre>
<p>Then load the stylesheet by passing it to the textField object inside the textArea.</p>
<pre class="actionscript"><span style="color: #000000; font-weight: bold;">var</span> myTextArea = <span style="color: #000000; font-weight: bold;">new</span> doopingTextArea<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
myTextArea.<span style="color: #0066CC;">textField</span>.<span style="color: #006600;">styleSheet</span> = styleSheetObject;</pre>
<p>As you can see we simply check if a styleSheet exists and than decide whether or not to do the original text formatting or not. Now we're able to use CSS on TextArea's and keep styling and code neatly separated.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sharedknowhow.com/2008/07/fixed-flash-textarea-css-incompatibility/feed/</wfw:commentRss>
		<slash:comments>30</slash:comments>
		</item>
	</channel>
</rss>
