<?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>ClickPopMedia &#187; Filters</title>
	<atom:link href="http://www.clickpopmedia.com/tag/filters/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.clickpopmedia.com</link>
	<description>ClickPopMedia is a great little design and illustration firm.</description>
	<lastBuildDate>Thu, 03 Dec 2009 17:28:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Realistic Shadow Effects using Filters</title>
		<link>http://www.clickpopmedia.com/2008/06/11/realistic-shadow-effects-using-filters/</link>
		<comments>http://www.clickpopmedia.com/2008/06/11/realistic-shadow-effects-using-filters/#comments</comments>
		<pubDate>Wed, 11 Jun 2008 15:37:42 +0000</pubDate>
		<dc:creator>Paul</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Paul]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[DropShadowFilter]]></category>
		<category><![CDATA[Filters]]></category>

		<guid isPermaLink="false">http://www.clickpopmedia.com/?p=329</guid>
		<description><![CDATA[
I have another simple but neat, little tutorial here on Flash CS3 filters.  This time I&#8217;m not using Tweens at all.  Our effect is going to use the MouseEvent.MOUSE_MOVE event to create the illusion of a light source coming from our cursor.

To begin with we are going to make our Shadows class.  [...]]]></description>
			<content:encoded><![CDATA[<pre><center><embed src="http://www.clickpopmedia.com/wp-content/uploads/2008/06/shadows.swf" width="550" height="400" allowscriptaccess="always" allowfullscreen="true"></center></pre>
<p>I have another simple but neat, little tutorial here on Flash CS3 filters.  This time I&#8217;m not using <strong>Tweens</strong> at all.  Our effect is going to use the <strong>MouseEvent.MOUSE_MOVE</strong> event to create the illusion of a light source coming from our cursor.</p>
<p><span id="more-329"></span></p>
<p>To begin with we are going to make our Shadows class.  This class is going to extend <strong>MovieClip</strong>, have a <strong>DropShadowFilter</strong> pre-applied to it and a public method to change the drop shadow filters distance and angle.</p>
<div class="dean_ch" style="white-space: wrap;"><span class="kw3">public</span> <span class="kw2">class</span> Shadows <span class="kw3">extends</span> <span class="kw3">MovieClip</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">public</span> <span class="kw3">static</span> <span class="kw2">var</span> All:<span class="kw3">Array</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; protected <span class="kw2">var</span> txtF:<span class="kw3">TextField</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; protected <span class="kw2">var</span> drop:DropShadowFilter;<br />
&nbsp; &nbsp; &nbsp; &nbsp; protected <span class="kw2">var</span> distance:<span class="kw3">Number</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; protected <span class="kw2">var</span> angle:<span class="kw3">Number</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; protected <span class="kw2">var</span> dropAlpha:<span class="kw3">Number</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; protected <span class="kw2">var</span> blurX:<span class="kw3">Number</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; protected <span class="kw2">var</span> blurY:<span class="kw3">Number</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">public</span> <span class="kw2">function</span> Shadows<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>Shadows.<span class="me1">All</span> == <span class="kw2">null</span><span class="br0">&#41;</span> Shadows.<span class="me1">All</span> = <span class="kw2">new</span> <span class="kw3">Array</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; distance = <span class="nu0">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; angle = <span class="nu0">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dropAlpha = <span class="nu0">1</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; blurX = <span class="nu0">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; blurX = <span class="nu0">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; drop = <span class="kw2">new</span> DropShadowFilter<span class="br0">&#40;</span>distance, angle, <span class="nu0">0</span>, dropAlpha, blurX, blurY<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">this</span>.<span class="me1">filters</span> = <span class="br0">&#91;</span>drop<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Shadows.<span class="me1">All</span>.<span class="kw3">push</span><span class="br0">&#40;</span><span class="kw3">this</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">public</span> <span class="kw2">function</span> lightSource<span class="br0">&#40;</span>X:<span class="kw3">Number</span>, Y:<span class="kw3">Number</span><span class="br0">&#41;</span>:<span class="kw3">void</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> dx:<span class="kw3">Number</span> = <span class="br0">&#40;</span><span class="kw3">this</span>.<span class="me1">x</span> + <span class="br0">&#40;</span><span class="kw3">this</span>.<span class="kw3">width</span>/<span class="nu0">2</span><span class="br0">&#41;</span><span class="br0">&#41;</span>-X;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> dy:<span class="kw3">Number</span> = <span class="br0">&#40;</span><span class="kw3">this</span>.<span class="me1">y</span> + <span class="br0">&#40;</span><span class="kw3">this</span>.<span class="kw3">height</span>/<span class="nu0">2</span><span class="br0">&#41;</span><span class="br0">&#41;</span>-Y;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; angle = <span class="br0">&#40;</span><span class="nu0">180</span> * <span class="kw3">Math</span>.<span class="kw3">atan</span><span class="br0">&#40;</span>dy/dx<span class="br0">&#41;</span><span class="br0">&#41;</span> / <span class="kw3">Math</span>.<span class="kw3">PI</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>dx &lt; <span class="nu0">0</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; angle += <span class="nu0">180</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; distance = <span class="kw3">Math</span>.<span class="kw3">sqrt</span><span class="br0">&#40;</span>dy*dy + dx*dx<span class="br0">&#41;</span>/<span class="nu0">10</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dropAlpha = <span class="nu0">10</span>/distance;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; blurX = <span class="kw3">Math</span>.<span class="kw3">abs</span><span class="br0">&#40;</span>dx/<span class="nu0">20</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; blurY = <span class="kw3">Math</span>.<span class="kw3">abs</span><span class="br0">&#40;</span>dy/<span class="nu0">20</span><span class="br0">&#41;</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; drop = <span class="kw2">new</span> DropShadowFilter<span class="br0">&#40;</span>distance, angle, <span class="nu0">0</span>, dropAlpha, blurX, blurY<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">this</span>.<span class="me1">filters</span> = <span class="br0">&#91;</span>drop<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div>
<p>I hope  you can see what is going on in the code.  I&#8217;m simply setting all my variables equal to 0 or 1, depending on what it&#8217;s for, and applying my filter in the constructor.  Also note that I&#8217;m saving all my objects in a static array.  This makes it easier to call all the <strong>lightSource()</strong> methods at once in a for loop later.</p>
<p>In the <strong>lightSource()</strong> method we have a little bit of math that you might be unfamiliar with.<br />
My variables <strong>dy</strong> and <strong>dx</strong> stand for distance y or x and I&#8217;m setting them equal to the distance from the point given and the center of my ShadowObject.</p>
<p><strong>angle</strong> is going to be the angle of the drop shadow and it needs to be in degrees.  <strong>Math.atan()</strong> is called arc-tangent in the Trigonometry world and it gives your the value of the angle opposite the Y side of a right triangle in radians.  If that doesn&#8217;t make sense, just know that it&#8217;s giving me that angle I need, but in the wrong units. I convert it by multiplying by 180 and dividing by PI.<strong> Math.atan()</strong> only returns a value between -pi/2 and pi/2 (-90 to 90 degrees) which only covers half a circle, so I have to check if we actually need the other side.  And, that&#8217;s what my if() statement is for.</p>
<p><strong>distance</strong> is calculated using the Pythagorean theorem C^2 = A^2 + B^2 (and then divided by 10 otherwise it&#8217;s just too much).<strong></strong></p>
<p><strong>DropAlpha</strong>, <strong>blurX</strong>, and <strong>blurY</strong> are all set pretty clearly (blur has to be positive, thus the <strong>Math.abs()</strong> or absolute value).</p>
<p>Finally our function creates a new drop filter with our new values and applies it to our Shadow object.</p>
<p>Except for trying to remember the math involved, this one has been pretty easy so far, huh?  Well then, let&#8217;s try using it in a project!</p>
<div class="dean_ch" style="white-space: wrap;"><span class="kw2">var</span> str = <span class="kw2">new</span> <span class="kw3">String</span><span class="br0">&#40;</span><span class="st0">&quot;ClickPop&quot;</span><span class="br0">&#41;</span>;<br />
<span class="kw2">var</span> str2 = <span class="kw2">new</span> <span class="kw3">String</span><span class="br0">&#40;</span><span class="st0">&quot;Media&quot;</span><span class="br0">&#41;</span>;<br />
<span class="kw2">var</span> letter:Shadows;<br />
<span class="kw2">var</span> newX:<span class="kw3">Number</span> = <span class="nu0">30</span>;<br />
<span class="kw2">var</span> overLetter:<span class="kw3">TextField</span>;</p>
<p><span class="kw1">for</span><span class="br0">&#40;</span><span class="kw2">var</span> i=<span class="nu0">0</span>; i&lt;str.<span class="kw3">length</span>; i++<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; letter = <span class="kw2">new</span> Shadows<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; letter.<span class="me1">x</span> = newX;<br />
&nbsp; &nbsp; &nbsp; &nbsp; letter.<span class="me1">y</span> = <span class="nu0">80</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; overLetter = <span class="kw2">new</span> <span class="kw3">TextField</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; overLetter.<span class="kw3">text</span> = str.<span class="kw3">charAt</span><span class="br0">&#40;</span>i<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; overLetter.<span class="kw3">setTextFormat</span><span class="br0">&#40;</span><span class="kw2">new</span> <span class="kw3">TextFormat</span><span class="br0">&#40;</span><span class="st0">&quot;Georgia&quot;</span>, <span class="nu0">100</span>, 0&#215;0000FF, <span class="kw2">true</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; overLetter.<span class="kw3">autoSize</span> = TextFieldAutoSize.<span class="kw3">LEFT</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; letter.<span class="me1">addChild</span><span class="br0">&#40;</span>overLetter<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; addChild<span class="br0">&#40;</span>letter<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; newX += letter.<span class="kw3">width</span>;<br />
<span class="br0">&#125;</span><br />
newX = <span class="nu0">80</span>;<br />
<span class="kw1">for</span><span class="br0">&#40;</span>i=<span class="nu0">0</span>; i&lt;str2.<span class="kw3">length</span>; i++<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; letter = <span class="kw2">new</span> Shadows<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; letter.<span class="me1">x</span> = newX;<br />
&nbsp; &nbsp; &nbsp; &nbsp; letter.<span class="me1">y</span> = <span class="nu0">180</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; overLetter = <span class="kw2">new</span> <span class="kw3">TextField</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; overLetter.<span class="kw3">text</span> = str2.<span class="kw3">charAt</span><span class="br0">&#40;</span>i<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; overLetter.<span class="kw3">setTextFormat</span><span class="br0">&#40;</span><span class="kw2">new</span> <span class="kw3">TextFormat</span><span class="br0">&#40;</span><span class="st0">&quot;Georgia&quot;</span>, <span class="nu0">100</span>, 0&#215;0000FF, <span class="kw2">true</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; overLetter.<span class="kw3">autoSize</span> = TextFieldAutoSize.<span class="kw3">LEFT</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; letter.<span class="me1">addChild</span><span class="br0">&#40;</span>overLetter<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; addChild<span class="br0">&#40;</span>letter<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; newX += letter.<span class="kw3">width</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw2">function</span> changeLight<span class="br0">&#40;</span>event:MouseEvent<span class="br0">&#41;</span>:<span class="kw3">void</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span><span class="br0">&#40;</span><span class="kw2">var</span> i=<span class="nu0">0</span>; i&lt;Shadows.<span class="me1">All</span>.<span class="kw3">length</span>; i++<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Shadows.<span class="me1">All</span><span class="br0">&#91;</span>i<span class="br0">&#93;</span>.<span class="me1">lightSource</span><span class="br0">&#40;</span><span class="kw3">stage</span>.<span class="me1">mouseX</span>, <span class="kw3">stage</span>.<span class="me1">mouseY</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span><br />
<span class="kw3">stage</span>.<span class="me1">addEventListener</span><span class="br0">&#40;</span>MouseEvent.<span class="me1">MOUSE_MOVE</span>, changeLight<span class="br0">&#41;</span>;</div>
<p>So, there it is.  I&#8217;m adding each letter to a different Shadow object so that their shadows move independently.  I then update all the shadow light sources to the mouse&#8217;s X and Y coordinates every time the mouse moves.  SO EASY!!</p>
<p>I have a few more ideas for cool effects that you can make with filters and I will probably post about them soon.</p>
<p>Download the Source Code for the example used in this post here: <a href="http://www.clickpopmedia.com/wp-content/uploads/2008/06/shadows.zip">ShadowsSource.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.clickpopmedia.com/2008/06/11/realistic-shadow-effects-using-filters/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Cool Rollover Effects with Filters</title>
		<link>http://www.clickpopmedia.com/2008/05/28/cool-rollover-effects-with-filters/</link>
		<comments>http://www.clickpopmedia.com/2008/05/28/cool-rollover-effects-with-filters/#comments</comments>
		<pubDate>Wed, 28 May 2008 05:15:51 +0000</pubDate>
		<dc:creator>Paul</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Paul]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Filters]]></category>
		<category><![CDATA[Menu]]></category>
		<category><![CDATA[Rollover Effects]]></category>

		<guid isPermaLink="false">http://www.clickpopmedia.com/?p=317</guid>
		<description><![CDATA[
Above is a little example menu I made for a fake game called &#8220;Top Secret.&#8221;  Don&#8217;t expect a game to start when you click on the Play button.  Instead, when you click a button you will get a little menu to change the rollover effects of said button.
What I&#8217;m going to be talking [...]]]></description>
			<content:encoded><![CDATA[<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="550" height="400" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.clickpopmedia.com/wp-content/uploads/2008/05/topsecret.swf" /><embed type="application/x-shockwave-flash" width="550" height="400" src="http://www.clickpopmedia.com/wp-content/uploads/2008/05/topsecret.swf"></embed></object></p>
<p>Above is a little example menu I made for a fake game called &#8220;Top Secret.&#8221;  Don&#8217;t expect a game to start when you click on the Play button.  Instead, when you click a button you will get a little menu to change the rollover effects of said button.</p>
<p>What I&#8217;m going to be talking about for the next&#8230; however long you read this, is how to recreate these cool effects for your own projects. Hopefully you will come up with some better ideas for using filters then just rollover effects.<br />
<span id="more-317"></span><br />
<strong>Setting Up The Example:</strong><br />
I simply typed all the text you see using whatever font seemed nice.  I then selected each TextField and broke them apart by pressing Ctrl+B twice.  After making each button into a MovieClip and giving them appropriate instance names (i.e. the Play button has a name of &#8220;<strong>play_mc</strong>&#8221; and you can see this in the popup menu) I felt like it was high time to make some cool rollover effects!</p>
<p><strong>Working w/ The Code:</strong><br />
I&#8217;m just going to talk about the one filter here, since the others are all pretty much the same.</p>
<p>To make a blur effect we need to create a new AS class file (one for each button).  We are going to use Tweens, Filters, Events, and we are extending a MovieClip, so we need to import the apropriate library classes for those:</p>
<div class="dean_ch" style="white-space: wrap;"><span class="kw3">import</span> flash.<span class="me1">display</span>.<span class="me1">*</span>;<br />
<span class="kw3">import</span> flash.<span class="me1">events</span>.<span class="me1">*</span>;<br />
<span class="kw3">import</span> flash.<span class="me1">filters</span>.<span class="me1">*</span>;<br />
<span class="kw3">import</span> fl.<span class="me1">transitions</span>.<span class="me1">*</span>;<br />
<span class="kw3">import</span> fl.<span class="me1">transitions</span>.<span class="me1">easing</span>.<span class="me1">*</span>;</div>
<p>The star in <strong>flash.events.*;</strong> just means &#8220;all of them&#8221; and it&#8217;s a quick way of importing lots of stuff at once.</p>
<p>Start out with making and applying our filter to get an idea of what we want:</p>
<div class="dean_ch" style="white-space: wrap;">blur = <span class="kw2">new</span> BlurFilter<span class="br0">&#40;</span><span class="nu0">8</span>, <span class="nu0">4</span>, <span class="nu0">1</span><span class="br0">&#41;</span>; <span class="co1">//blurX, blurY, quality</span><br />
<span class="kw3">this</span>.<span class="me1">filters</span> = <span class="br0">&#91;</span>blur<span class="br0">&#93;</span>;</div>
<p>This is the default value/filter you see before you change any settings in my example movie above.</p>
<p>The <strong>filters</strong> property that I&#8217;m setting in the above code is an Array property of any DisplayObject (including Sprites, MovieClips, and any other children thereof).  That is why I need the square brackets, because it&#8217;s an Array.</p>
<p>With the filter in place we need to check for our <strong>MOUSE_OVER</strong> and <strong>MOUSE_OUT</strong> events and tween the blur filter.</p>
<p>A <strong>Tween</strong> object can change any <strong>Number</strong> property of almost any object over time using <strong>easing functions</strong>.  To read more on Tweens you can check out <a href="http://www.clickpopmedia.com/2008/03/10/tween-intro/">Intro to ActionScript 3.0 Tweening</a>.</p>
<div class="dean_ch" style="white-space: wrap;">protected <span class="kw2">var</span> blurX_tw:Tween;<br />
protected <span class="kw2">var</span> blurY_tw:Tween;</p>
<p><span class="kw3">public</span> <span class="kw2">function</span> <span class="coMULTI">/*CONSTRUCTOR*/</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">this</span>.<span class="me1">addEventListener</span><span class="br0">&#40;</span>MouseEvent.<span class="me1">MOUSE_OVER</span>, Over<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">this</span>.<span class="me1">addEventListener</span><span class="br0">&#40;</span>MouseEvent.<span class="me1">MOUSE_OUT</span>, Out<span class="br0">&#41;</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; blurX_tw = <span class="kw2">new</span> Tween<span class="br0">&#40;</span>blur, <span class="st0">&quot;blurX&quot;</span>, Regular.<span class="me1">easeInOut</span>, <span class="nu0">8</span>, <span class="nu0">8</span>, <span class="nu0">1</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; blurX_tw.<span class="me1">addEventListener</span><span class="br0">&#40;</span>TweenEvent.<span class="me1">MOTION_CHANGE</span>, updateBlurFilter<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; blurY_tw = <span class="kw2">new</span> Tween<span class="br0">&#40;</span>blur, <span class="st0">&quot;blurY&quot;</span>, Regular.<span class="me1">easeInOut</span>, <span class="nu0">4</span>, <span class="nu0">4</span>, <span class="nu0">1</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; blurY_tw.<span class="me1">addEventListener</span><span class="br0">&#40;</span>TweenEvent.<span class="me1">MOTION_CHANGE</span>, updateBlurFilter<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
protected <span class="kw2">function</span> updateBlurFilter<span class="br0">&#40;</span><span class="kw3">e</span>:TweenEvent<span class="br0">&#41;</span>:<span class="kw3">void</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">this</span>.<span class="me1">filters</span> = <span class="br0">&#91;</span><span class="kw3">e</span>.<span class="me1">currentTarget</span>.<span class="me1">obj</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span><br />
protected <span class="kw2">function</span> Over<span class="br0">&#40;</span>event:MouseEvent<span class="br0">&#41;</span>:<span class="kw3">void</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; blurX_tw.<span class="me1">continueTo</span><span class="br0">&#40;</span><span class="nu0">0</span>, <span class="nu0">10</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; blurY_tw.<span class="me1">continueTo</span><span class="br0">&#40;</span><span class="nu0">0</span>, <span class="nu0">10</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
protected <span class="kw2">function</span> Out<span class="br0">&#40;</span>event:MouseEvent<span class="br0">&#41;</span>:<span class="kw3">void</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; blurX_tw.<span class="me1">continueTo</span><span class="br0">&#40;</span><span class="nu0">8</span>, <span class="nu0">15</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; blurY_tw.<span class="me1">continueTo</span><span class="br0">&#40;</span><span class="nu0">4</span>, <span class="nu0">15</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></div>
<p>Ah! Well there we go.  We now have a tween that effects our X&amp;Y blur. Notice that we have an event listener on those two tweens for <strong>TweenEvent.MOTION_CHANGE</strong>.  This is because the blur filter that we are tweening is NOT the filter that is on our MovieClip.  So for every step that the tween changes the blur values, we need to reapply the filter to our Button.</p>
<p>I&#8217;m sure you have noticed that I am making most of my functions and variables <strong>protected</strong>.  This is because <strong>protected</strong> is just like <strong>private</strong>, but private will not be inherited by child classes and protected will.  I want to keep inheritance because this way I can (and have) make a base class with all my effects and just have my button classes extend that base.</p>
<p>If you download the source for my example movie <a href="http://www.clickpopmedia.com/wp-content/uploads/2008/05/topsecretsource.zip">HERE</a>, you will notice that I have almost all my code within the Rollover class and all my button classes are extending that one.</p>
<p>Once again, you can download the source for this tutorial and example movie here: <a href="http://www.clickpopmedia.com/wp-content/uploads/2008/05/topsecretsource.zip">TopSecret Example Source Code (ZIP &#8211; 958 KB)</a></p>
<p>If you are interested in some of the components I used or want to know more about working with colors, let me know in a comment and maybe I will make a separate tutorial on them.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.clickpopmedia.com/2008/05/28/cool-rollover-effects-with-filters/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

