<?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>zedia flash blog &#187; Skinning</title>
	<atom:link href="http://www.zedia.net/tag/skinning/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zedia.net</link>
	<description>Flash, ActionScript, SEO and everything in between</description>
	<lastBuildDate>Thu, 02 Feb 2012 17:58:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Skinning the ComboBox Flash component</title>
		<link>http://www.zedia.net/2010/skinning-the-combobox-flash-component/</link>
		<comments>http://www.zedia.net/2010/skinning-the-combobox-flash-component/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 16:12:56 +0000</pubDate>
		<dc:creator>zedia.net</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[ComboBox]]></category>
		<category><![CDATA[Font]]></category>
		<category><![CDATA[setRendererStyle]]></category>
		<category><![CDATA[Skinning]]></category>

		<guid isPermaLink="false">http://www.zedia.net/?p=550</guid>
		<description><![CDATA[This post is more for me because I keep forgetting how to do this. For my defense I have to say that it is not exactly the first thing that comes to mind when you are trying to change the font in the ComboBox component, but at least I won&#8217;t have to remember in which [...]]]></description>
			<content:encoded><![CDATA[<p>This post is more for me because I keep forgetting how to do this. For my defense I have to say that it is not exactly the first thing that comes to mind when you are trying to change the font in the ComboBox component, but at least I won&#8217;t have to remember in which project I did it; I&#8217;ll just turn to my friend Google and type : comboBox + zedia.</p>
<p>Editing the visual is mostly easy inside of flash but my main problem is always the fonts. In a <a title="Fonts are my bane" href="http://www.zedia.net/2010/fonts-are-my-bane-not-anymore/" target="_self">previous post</a> I talked about fonts in Flash in general, this one will use that as a base and apply it to the ComboBox. Here is the code to change the font in the textfield and the dropping list:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> myFormatWhite:<span style="color: #0066CC;">TextFormat</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextFormat</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
myFormatWhite.<span style="color: #0066CC;">font</span> = <span style="color: #ff0000;">&quot;DFC GillSansLight&quot;</span>;
myFormatWhite.<span style="color: #0066CC;">size</span> = <span style="color: #cc66cc;">15</span>;
myFormatWhite.<span style="color: #0066CC;">color</span> = 0xffffff;
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> myFormatBeige:<span style="color: #0066CC;">TextFormat</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextFormat</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
myFormatBeige.<span style="color: #0066CC;">font</span> = <span style="color: #ff0000;">&quot;DFC GillSansLight&quot;</span>;
myFormatBeige.<span style="color: #0066CC;">size</span> = <span style="color: #cc66cc;">14</span>;
myFormatBeige.<span style="color: #0066CC;">color</span> = 0xa18c52;
&nbsp;
comboBox.<span style="color: #0066CC;">textField</span>.<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;embedFonts&quot;</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
comboBox.<span style="color: #0066CC;">textField</span>.<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;textFormat&quot;</span>, myFormatWhite<span style="color: #66cc66;">&#41;</span>;<span style="color: #66cc66;">&amp;</span>lt;
&nbsp;
comboBox.<span style="color: #006600;">dropdown</span>.<span style="color: #006600;">setRendererStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;embedFonts&quot;</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
comboBox.<span style="color: #006600;">dropdown</span>.<span style="color: #006600;">setRendererStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;textFormat&quot;</span>, myFormatBeige<span style="color: #66cc66;">&#41;</span>;
&nbsp;
comboBox.<span style="color: #006600;">prompt</span> = <span style="color: #ff0000;">&quot;Province&quot;</span>; <span style="color: #808080; font-style: italic;">//default value that won't show in the dropdown</span>
comboBox.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> label:<span style="color: #ff0000;">&quot;New Brunswick&quot;</span>, <span style="color: #0066CC;">data</span>:<span style="color: #ff0000;">&quot;New Brunswick&quot;</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
comboBox.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> label:<span style="color: #ff0000;">&quot;Nova Scotia&quot;</span>, <span style="color: #0066CC;">data</span>:<span style="color: #ff0000;">&quot;Nova Scotia&quot;</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
comboBox.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> label:<span style="color: #ff0000;">&quot;Ontario&quot;</span>, <span style="color: #0066CC;">data</span>:<span style="color: #ff0000;">&quot;Ontario&quot;</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
comboBox.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> label:<span style="color: #ff0000;">&quot;Prince Edward Island&quot;</span>, <span style="color: #0066CC;">data</span>:<span style="color: #ff0000;">&quot;Prince Edward Island&quot;</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>My problem was mostly with the setRendererStyle method; not that obvious. I also put the code for adding items in the ComboBox and to have a default text in it that doesn&#8217;t show in the dropdown. Now the next bit of code if to check, when you used ComboBox.prompt, if something was selected:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>comboBox.<span style="color: #006600;">selectedIndex</span> == -<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
<span style="color: #808080; font-style: italic;">//show error message because comboBox wasn't changed</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>P.S. all this code assumes that I have dragged the component to the stage in the Flash IDE</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zedia.net/2010/skinning-the-combobox-flash-component/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

