<?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>FlexWiz Blog &#187; Quick Tips</title>
	<atom:link href="http://blog.flexwiz.net/category/tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexwiz.net</link>
	<description>On Game Development and the Flash platform</description>
	<lastBuildDate>Sat, 17 Dec 2011 22:46:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Tip: Easy Spark Icon Button</title>
		<link>http://blog.flexwiz.net/tip-easy-spark-icon-button/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=tip-easy-spark-icon-button</link>
		<comments>http://blog.flexwiz.net/tip-easy-spark-icon-button/#comments</comments>
		<pubDate>Fri, 11 Jun 2010 13:27:28 +0000</pubDate>
		<dc:creator>theWiz</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Quick Tips]]></category>
		<category><![CDATA[Skinning]]></category>
		<category><![CDATA[Spark]]></category>

		<guid isPermaLink="false">http://flexwiz.amosl.com/?p=268</guid>
		<description><![CDATA[I needed a simple spark button with only an icon &#8211; basically a bitmap made into a button. The problem is that I have lots of these buttons, each with a different icon &#8211; and all the skin samples use hard-coded assets. UPDATE:  The new Flex 4.5 Hero has this feature built in, as described in [...]]]></description>
			<content:encoded><![CDATA[<p>I needed a simple spark button with only an icon &#8211; basically a bitmap made into a button. The problem is that I have lots of these buttons, each with a different icon &#8211; and all the skin samples use hard-coded assets.</p>
<p>UPDATE:  The new Flex 4.5 Hero has this feature built in, as described in<a href="http://blog.flexwiz.net/flex/flex-4-5-a-hero-welcome/" target="_blank"> this recent post</a>.</p>
<p>Well, the old Button class used to have an icon style (it was called skin or upSkin) so I decided to bring back the icon style so I&#8217;d be able to reuse the same skin and pass a different icon to each instance.<br />
<span id="more-268"></span></p>
<p>Usage:</p>
<p>The IconButton class:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> cs
<span style="color: #000000;">&#123;</span>
        <span style="color: #009900; font-style: italic;">// icon style</span>
	<span style="color: #000000;">&#91;</span>Style<span style="color: #000000;">&#40;</span><span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;icon&quot;</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #004993;">type</span>=<span style="color: #990000;">&quot;*&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> IconButton <span style="color: #0033ff; font-weight: bold;">extends</span> Button
	<span style="color: #000000;">&#123;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Now the generic icon button skin (IconBtnSkin):</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fx:Metadata<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		[HostComponent(&quot;cc.IconButton&quot;)] 
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/fx:Metadata<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:states<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:State</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;up&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span> 
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:State</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;over&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span> 
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:State</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;down&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span> 
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:State</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;disabled&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span> 
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/s:states<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>  
&nbsp;
	<span style="color: #808080; font-style: italic;">&lt;!-- icon --&gt;</span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:BitmapImage</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;{hostComponent.getStyle('icon')}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>To use, just use the skin with the IconButton class, and set the icon style to the asset of choice:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;cc:IconButton</span> <span style="color: #000066;">skin</span>=<span style="color: #ff0000;">&quot;IconBtnSkin&quot;</span> <span style="color: #000066;">icon</span>=<span style="color: #ff0000;">&quot;myAsset&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></pre></div></div>

<p>You can also couple the skin with the IconButton class explicitly by setting the skinClass from the constructor:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">	<span style="color: #004993;">setStyle</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;skinClass&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;skins.IconBtnSkin&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.flexwiz.net/tip-easy-spark-icon-button/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Tip: Dump any object to trace quickly</title>
		<link>http://blog.flexwiz.net/tip-dump-any-object-to-trace-quickly/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=tip-dump-any-object-to-trace-quickly</link>
		<comments>http://blog.flexwiz.net/tip-dump-any-object-to-trace-quickly/#comments</comments>
		<pubDate>Wed, 12 May 2010 00:36:03 +0000</pubDate>
		<dc:creator>theWiz</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Quick Tips]]></category>
		<category><![CDATA[Debug]]></category>

		<guid isPermaLink="false">http://flexwiz.amosl.com/?p=237</guid>
		<description><![CDATA[Heres a useful tip on using the mx utils package. Occasionally we need to trace values of objects, whether these are flash display objects or your own classes and VOs.   Simply outputting an object to trace will generate an output like [Object Object] without any useful info about the contents of the object. Enter mx.Utils and [...]]]></description>
			<content:encoded><![CDATA[<p>Heres a useful tip on using the mx utils package.</p>
<p>Occasionally we need to trace values of objects, whether these are flash display objects or your own classes and VOs.   Simply outputting an object to trace will generate an output like [Object Object] without any useful info about the contents of the object.<br />
<span id="more-237"></span></p>
<p>Enter mx.Utils and its helper classes. ObjectUtil is a nifty little class that contains some helper functions (check it out on Adobe live docs) and the static toString() implementation offers to &#8216;pretty print&#8217; any object.</p>
<p>Simply type:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">        <span style="color: #009900; font-style: italic;">// assume myObject is defined elsewhere</span>
&nbsp;
        <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>ObjectUtil<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">toString</span><span style="color: #000000;">&#40;</span>myObject<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

<p>and replace your object as the function argument.</p>
<p>Short example:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">        <span style="color: #6699cc; font-weight: bold;">var</span> point<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Point</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Point</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">100</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">100</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
        <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>ObjectUtil<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">toString</span><span style="color: #000000;">&#40;</span>point<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
    <span style="color: #009900; font-style: italic;">//Will output:</span>
    <span style="color: #000000;">&#40;</span><span style="color: #004993;">flash.geom</span><span style="color: #000066; font-weight: bold;">::</span><span style="color: #004993;">Point</span><span style="color: #000000;">&#41;</span>
         <span style="color: #004993;">length</span> = <span style="color: #000000; font-weight:bold;">141.4213562373095</span>
         <span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">100</span>
         <span style="color: #004993;">y</span> = <span style="color: #000000; font-weight:bold;">100</span></pre></div></div>

<p>Try it out!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.flexwiz.net/tip-dump-any-object-to-trace-quickly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Transparent buttons in Flex &#8211; the easy way</title>
		<link>http://blog.flexwiz.net/making-your-flex-button-transparent/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=making-your-flex-button-transparent</link>
		<comments>http://blog.flexwiz.net/making-your-flex-button-transparent/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 03:29:48 +0000</pubDate>
		<dc:creator>theWiz</dc:creator>
				<category><![CDATA[Quick Tips]]></category>
		<category><![CDATA[Button]]></category>

		<guid isPermaLink="false">http://flexwiz.amosl.com/?p=11</guid>
		<description><![CDATA[Making a flex button appear flat or transparent does not require any skinning &#8211; there are plenty of style options, and all we need to do is find the right setting. This may sound trivial, since we can make any display object clickable &#8211; but since I find myself spending way too much time on [...]]]></description>
			<content:encoded><![CDATA[<p>Making a flex button appear flat or transparent does not require any skinning &#8211; there  are plenty of style options, and all we need to do is find the right setting.<br />
This may sound trivial, since we can make any display object clickable &#8211; but since I find myself spending way too much time on this, its time to put this issue to rest.</p>
<p style="text-align: center;">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_ButtonSample_234367767"
			class="flashmovie"
			width="400"
			height="90">
	<param name="movie" value="wp-content/uploads/2010/02/ButtonSample.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="wp-content/uploads/2010/02/ButtonSample.swf"
			name="fm_ButtonSample_234367767"
			width="400"
			height="90">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>The Flex framework button class (mx.Button) has a default skin &#8211; the halo button skin. I needed a button with no background or highlight &#8211; basically a clickable text. Simply setting the background alpha to zero seem to have no effect.<br />
<span id="more-481"></span><br />
So since the halo skin is being shown anyway, lets try to remove it from the button tag in mxml:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Button</span> <span style="color: #000066;">skin</span>=<span style="color: #ff0000;">'null'</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>This will result in a build error:</p>
<ul>
Initializer for &#8216;skin&#8217;: cannot parse value of type Class from text &#8216;null&#8217;.  </ul>
<p>To fix it, put the null inside curly brackets:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Button</span> <span style="color: #000066;">skin</span>=<span style="color: #ff0000;">'{null}'</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>Alternatively, we can turn to CSS and define a style for the button:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.myButtonStyle</span> <span style="color: #00AA00;">&#123;</span>
	skin<span style="color: #00AA00;">:</span>	ClassReference<span style="color: #00AA00;">&#40;</span>null<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Now just use the the style in the button:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Button</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;myButton&quot;</span> <span style="color: #000066;">styleName</span>=<span style="color: #ff0000;">'myButtonStyle'</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>The same can be achieved in actionscript code with this line, placed in the script tag:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">myButton.<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'skin'</span>, <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>Download the full source code <a href="files/ButtonSample.zip">here</a>.</p>
<p>UPDATE:</p>
<p>For Flex 4, the Spark model requires skin so this approach will not work. Simply create a new spark skin for button and remove all drawing except for the label. Name the skin &#8216;TransparentButtonSkin&#8217; and in your button set the skinClass the TransparentButtonSkin you just created.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.flexwiz.net/making-your-flex-button-transparent/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

