<?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"
	>

<channel>
	<title>ClickPopMedia</title>
	<atom:link href="http://www.clickpopmedia.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.clickpopmedia.com</link>
	<description>ClickPopMedia is a great little design and illustration firm.</description>
	<pubDate>Fri, 27 Jun 2008 02:10:53 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Free Vector Octopus</title>
		<link>http://www.clickpopmedia.com/2008/06/26/free-vector-octopus/</link>
		<comments>http://www.clickpopmedia.com/2008/06/26/free-vector-octopus/#comments</comments>
		<pubDate>Fri, 27 Jun 2008 02:10:53 +0000</pubDate>
		<dc:creator>VQ</dc:creator>
		
		<category><![CDATA[Download]]></category>

		<category><![CDATA[Free]]></category>

		<category><![CDATA[Products]]></category>

		<category><![CDATA[VQ]]></category>

		<category><![CDATA[Vector]]></category>

		<category><![CDATA[cartoon]]></category>

		<category><![CDATA[freebie]]></category>

		<category><![CDATA[octopus]]></category>

		<guid isPermaLink="false">http://www.clickpopmedia.com/?p=351</guid>
		<description><![CDATA[
Today is your luck day, friend. It&#8217;s free octopus day at ClickPopMedia! So step up [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img src="http://www.clickpopmedia.com/wp-content/uploads/2008/06/header1.jpg" alt="" /></p>
<p style="text-align: left;">Today is your luck day, friend. It&#8217;s free octopus day at ClickPopMedia! So step up and download yourself an octopus.</p>
<p style="text-align: center;"><a href="http://www.clickpopmedia.com/Freebies/octopus.zip"><strong>Download the Vector Octopus (.ai and .eps)</strong></a></p>
<h3>Related Posts</h3>
<ul class="related_post">
<li><a href="http://www.clickpopmedia.com/2008/05/09/free-vector-platypus-swimmer/" title="Free Vector: Platypus Swimmer">Free Vector: Platypus Swimmer (1)</a></li>
<li><a href="http://www.clickpopmedia.com/2008/04/21/free-vectors-speech-bubbles/" title="Free Vectors: Speech Bubbles">Free Vectors: Speech Bubbles (4)</a></li>
<li><a href="http://www.clickpopmedia.com/2008/06/18/water-buffalo-skull-vector/" title="Water Buffalo Skull Vector">Water Buffalo Skull Vector (0)</a></li>
<li><a href="http://www.clickpopmedia.com/2008/06/05/batik-is-beautiful/" title="Batik is Beautiful - Free Vector Swatches UPDATED">Batik is Beautiful - Free Vector Swatches UPDATED (15)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.clickpopmedia.com/2008/06/26/free-vector-octopus/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Easy Keyboard Controls and Game Design</title>
		<link>http://www.clickpopmedia.com/2008/06/25/easy-keyboard-controls-and-game-design/</link>
		<comments>http://www.clickpopmedia.com/2008/06/25/easy-keyboard-controls-and-game-design/#comments</comments>
		<pubDate>Thu, 26 Jun 2008 01:21:07 +0000</pubDate>
		<dc:creator>Paul</dc:creator>
		
		<category><![CDATA[ActionScript]]></category>

		<category><![CDATA[Paul]]></category>

		<category><![CDATA[Tutorials]]></category>

		<category><![CDATA[Asteroids]]></category>

		<category><![CDATA[Game Development]]></category>

		<category><![CDATA[Keyboard]]></category>

		<guid isPermaLink="false">http://www.clickpopmedia.com/?p=340</guid>
		<description><![CDATA[
In this tutorial I will be going over some of the basic elements to making [...]]]></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/06/asteroids.swf" /><embed type="application/x-shockwave-flash" width="550" height="400" src="http://www.clickpopmedia.com/wp-content/uploads/2008/06/asteroids.swf"></embed></object><br />
In this tutorial I will be going over some of the basic elements to making a game in Flash. This being the first in a short series of tutorials on the subject, I will cover the main game loop and keyboard controls.<br />
<span id="more-340"></span><br />
First off we need to set up some simple graphics.  I did some REALLY simple graphics as you can see.  The <strong>ship_mc</strong> being just a triangle and on the 3rd frame of the ship movie clip it get&#8217;s a little fire tail.  Since I am just imitating <em>Atari Interactive, Inc.</em>&#8217;s<em> Asteroids</em>, we don&#8217;t really need anything more then that for now.<br />
Now, to get our initial code setup:</p>
<div class="dean_ch" style="white-space: wrap;">package <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">import</span> flash.<span class="me1">display</span>.<span class="me1">*</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">import</span> flash.<span class="me1">events</span>.<span class="me1">*</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">import</span> flash.<span class="kw3">text</span>.<span class="me1">*</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">import</span> flash.<span class="me1">utils</span>.<span class="me1">Timer</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">public</span> <span class="kw2">class</span> Asteroids <span class="kw3">extends</span> <span class="kw3">MovieClip</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; protected <span class="kw2">var</span> mainTimer:Timer;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">public</span> <span class="kw2">function</span> Asteroids<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mainTimer = <span class="kw2">new</span> Timer<span class="br0">&#40;</span><span class="nu0">20</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mainTimer.<span class="me1">addEventListener</span><span class="br0">&#40;</span>TimerEvent.<span class="me1">TIMER</span>, MainLoop<span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ship_mc.<span class="kw3">stop</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">this</span>.<span class="me1">addEventListener</span><span class="br0">&#40;</span>Event.<span class="me1">DEACTIVATE</span>, deactive<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">this</span>.<span class="me1">addEventListener</span><span class="br0">&#40;</span>Event.<span class="me1">ACTIVATE</span>, active<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">stage</span>.<span class="me1">addEventListener</span><span class="br0">&#40;</span>KeyboardEvent.<span class="me1">KEY_DOWN</span>, kDown<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">stage</span>.<span class="me1">addEventListener</span><span class="br0">&#40;</span>KeyboardEvent.<span class="me1">KEY_UP</span>, kUp<span class="br0">&#41;</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; protected <span class="kw2">function</span> MainLoop<span class="br0">&#40;</span><span class="kw3">e</span>:TimerEvent<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="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; protected <span class="kw2">function</span> deactive<span class="br0">&#40;</span><span class="kw3">e</span>:Event<span class="br0">&#41;</span>:<span class="kw3">void</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mainTimer.<span class="kw3">stop</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; protected <span class="kw2">function</span> active<span class="br0">&#40;</span><span class="kw3">e</span>:Event<span class="br0">&#41;</span>:<span class="kw3">void</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mainTimer.<span class="kw3">start</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; protected <span class="kw2">function</span> kDown<span class="br0">&#40;</span><span class="kw3">e</span>:KeyboardEvent<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="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; protected <span class="kw2">function</span> kUp<span class="br0">&#40;</span><span class="kw3">e</span>:KeyboardEvent<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="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div>
<p>So far this is just a skeleton of our game.  We have our <strong>KEY_DOWN</strong> and <strong>KEY_UP</strong> events which will handle all of our keyboard controls later.  But, more importantly, we have our <strong>mainTimer</strong>.  By setting up our game engine to run based on a timer I can later change the frame rate without changing the game dynamics (I left the frame rate at 12/sec for the example above).  This is also useful if your game has too many graphical elements and the frame rate drops on some machines, this will preserve the speed of the game itself.<br />
So, please notice that I have the Timer set to &#8220;tick&#8221; every 20 milliseconds (1000 milliseconds to 1 seconds) which is about 50 ticks per second. Because of that, we are going to have some small values to work with when playing with flight speed and rotation in our ship.<br />
But, first let us think about keyboard controls:</p>
<div class="dean_ch" style="white-space: wrap;">protected <span class="kw2">var</span> thrust:<span class="kw3">Boolean</span>;<br />
protected <span class="kw2">var</span> rpm:<span class="kw3">Number</span>;<br />
protected <span class="kw2">function</span> kDown<span class="br0">&#40;</span><span class="kw3">e</span>:KeyboardEvent<span class="br0">&#41;</span>:<span class="kw3">void</span> <span class="br0">&#123;</span><br />
<span class="co1">//&nbsp; &nbsp; &nbsp; trace(e.keyCode);</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><span class="kw3">e</span>.<span class="me1">keyCode</span> == <span class="nu0">37</span> || <span class="kw3">e</span>.<span class="me1">keyCode</span> == <span class="nu0">65</span> || <span class="kw3">e</span>.<span class="me1">keyCode</span> == <span class="nu0">100</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rpm = <span class="nu0">-4</span>;<br />
<span class="co1">//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; trace(&quot;LEFT&quot;);</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><span class="kw3">e</span>.<span class="me1">keyCode</span> == <span class="nu0">38</span> || <span class="kw3">e</span>.<span class="me1">keyCode</span> == <span class="nu0">87</span> || <span class="kw3">e</span>.<span class="me1">keyCode</span> == <span class="nu0">104</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; thrust = <span class="kw2">true</span>;<br />
<span class="co1">//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; trace(&quot;UP&quot;);</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><span class="kw3">e</span>.<span class="me1">keyCode</span> == <span class="nu0">39</span> || <span class="kw3">e</span>.<span class="me1">keyCode</span> == <span class="nu0">68</span> || <span class="kw3">e</span>.<span class="me1">keyCode</span> == <span class="nu0">102</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rpm = <span class="nu0">4</span>;<br />
<span class="co1">//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; trace(&quot;RIGHT&quot;);</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span><br />
protected <span class="kw2">function</span> kUp<span class="br0">&#40;</span><span class="kw3">e</span>:KeyboardEvent<span class="br0">&#41;</span>:<span class="kw3">void</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><span class="kw3">e</span>.<span class="me1">keyCode</span> == <span class="nu0">37</span> || <span class="kw3">e</span>.<span class="me1">keyCode</span> == <span class="nu0">65</span> || <span class="kw3">e</span>.<span class="me1">keyCode</span> == <span class="nu0">100</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rpm = <span class="nu0">0</span>;<br />
<span class="co1">//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; trace(&quot;LEFT&quot;);</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><span class="kw3">e</span>.<span class="me1">keyCode</span> == <span class="nu0">38</span> || <span class="kw3">e</span>.<span class="me1">keyCode</span> == <span class="nu0">87</span> || <span class="kw3">e</span>.<span class="me1">keyCode</span> == <span class="nu0">104</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; thrust = <span class="kw2">false</span>;<br />
<span class="co1">//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; trace(&quot;UP&quot;);</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><span class="kw3">e</span>.<span class="me1">keyCode</span> == <span class="nu0">39</span> || <span class="kw3">e</span>.<span class="me1">keyCode</span> == <span class="nu0">68</span> || <span class="kw3">e</span>.<span class="me1">keyCode</span> == <span class="nu0">102</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rpm = <span class="nu0">0</span>;<br />
<span class="co1">//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; trace(&quot;RIGHT&quot;);</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div>
<p><strong>rpm</strong> and <strong>thrust</strong> are going to control our ships flight in the <strong>MainLoop</strong> later.  The <strong>keyCode</strong> is a number which represents the key being pressed or released on the keyboard.  I prefer to set a value on down because the <strong>KEY_DOWN</strong> event will be fired off numerous times very quickly if the key is held too long.  I have the controls set up to work with WASD, the arrow keys, or the num pad.<br />
To find the key values I just traced <strong>e.keyCode</strong> in the <strong>kUp()</strong> function and tried pressing the keys in question.  This got me the numbers you see in the code above.  The commented out traces are there to make sure we have the correct keys, since we don&#8217;t have any other indicator yet.</p>
<p>The next step is a simple one (except for some of the math):</p>
<div class="dean_ch" style="white-space: wrap;">protected const TOP_SPEED:<span class="kw3">Number</span> = <span class="nu0">10</span>;<br />
protected const ACCELERATION:<span class="kw3">Number</span> = .<span class="nu0">1</span>;<br />
protected const FRICTION:<span class="kw3">Number</span> = .<span class="nu0">995</span>;</p>
<p>protected <span class="kw2">var</span> mainTimer:Timer;<br />
protected <span class="kw2">var</span> speedX:<span class="kw3">Number</span>;<br />
protected <span class="kw2">var</span> speedY:<span class="kw3">Number</span>;</p>
<p><span class="kw3">public</span> <span class="kw2">function</span> Asteroids<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; rpm = <span class="nu0">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; speedX = <span class="nu0">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; speedY = <span class="nu0">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &#8230;<br />
<span class="br0">&#125;</span></p>
<p>protected <span class="kw2">function</span> MainLoop<span class="br0">&#40;</span><span class="kw3">e</span>:TimerEvent<span class="br0">&#41;</span>:<span class="kw3">void</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; ship_mc.<span class="me1">rotation</span> += rpm;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> dx:<span class="kw3">Number</span> = ACCELERATION * <span class="kw3">Math</span>.<span class="kw3">cos</span><span class="br0">&#40;</span><span class="br0">&#40;</span>ship_mc.<span class="me1">rotation*</span><span class="kw3">Math</span>.<span class="kw3">PI</span><span class="br0">&#41;</span>/<span class="nu0">180</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> dy:<span class="kw3">Number</span> = ACCELERATION * <span class="kw3">Math</span>.<span class="kw3">sin</span><span class="br0">&#40;</span><span class="br0">&#40;</span>ship_mc.<span class="me1">rotation*</span><span class="kw3">Math</span>.<span class="kw3">PI</span><span class="br0">&#41;</span>/<span class="nu0">180</span><span class="br0">&#41;</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>thrust<span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; speedX += dx;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; speedY += dy;<br />
<span class="co1">//We want to have a max speed in any direction of the compass</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> speed = speedX*speedX + speedY*speedY;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>speed &gt;= TOP_SPEED*TOP_SPEED<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; speedX *= <span class="br0">&#40;</span>TOP_SPEED*TOP_SPEED<span class="br0">&#41;</span>/speed;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; speedY *= <span class="br0">&#40;</span>TOP_SPEED*TOP_SPEED<span class="br0">&#41;</span>/speed;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ship_mc.<span class="kw3">gotoAndStop</span><span class="br0">&#40;</span><span class="nu0">3</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ship_mc.<span class="kw3">gotoAndStop</span><span class="br0">&#40;</span><span class="nu0">1</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="co1">//I know there is no friction in space, but I can&#8217;t remember if Asteroids had it or not.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; speedX *= FRICTION;<br />
&nbsp; &nbsp; &nbsp; &nbsp; speedY *= FRICTION;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; ship_mc.<span class="me1">x</span> += speedX;<br />
&nbsp; &nbsp; &nbsp; &nbsp; ship_mc.<span class="me1">y</span> += speedY;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>ship_mc.<span class="me1">x</span> &gt; <span class="nu0">560</span><span class="br0">&#41;</span> ship_mc.<span class="me1">x</span> = <span class="nu0">-10</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>ship_mc.<span class="me1">x</span> &lt; <span class="nu0">-10</span><span class="br0">&#41;</span> ship_mc.<span class="me1">x</span> = <span class="nu0">560</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>ship_mc.<span class="me1">y</span> &gt; <span class="nu0">410</span><span class="br0">&#41;</span> ship_mc.<span class="me1">y</span> = <span class="nu0">-10</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>ship_mc.<span class="me1">y</span> &lt; <span class="nu0">-10</span><span class="br0">&#41;</span> ship_mc.<span class="me1">y</span> = <span class="nu0">410</span>;<br />
<span class="br0">&#125;</span></div>
<p>Here we have initialized some variables in the constructor first.  Then we filled in our <strong>MainLoop</strong> to give our spaceship some life.  I would think the <strong>rotation</strong> is self evident&#8230;  it&#8217;s the first line of the method.  I used some constants in my math (<strong>ACCELERATION, TOP_SPEED,</strong> and <strong>FRICTION</strong>) so that I can easily adjust the game settings all in one place, without searching for the parts of the code that I need changed.<br />
The last group of <strong>if</strong> statements above are checking to see in our ship has flown off the screen and if it has it will be moved to the other side.</p>
<p>That&#8217;s all for now.  Next time I will probably add some asteroids and talk a little about collision detection.</p>
<p>You can download the source for this example here: <a href="http://www.clickpopmedia.com/wp-content/uploads/2008/06/asteroidssource.rar">AsteroidsSource.rar</a><br />
<h3>Other Posts</h3>
<ul class="related_post">
<li><a href="http://www.clickpopmedia.com/2008/04/30/a-painting-collaborating/" title="A Painting Collaborating.">A Painting Collaborating. (0)</a></li>
<li><a href="http://www.clickpopmedia.com/2008/04/06/streams-in-the-city-psalm-4645/" title="Streams in the city (Psalm 46:4,5)">Streams in the city (Psalm 46:4,5) (0)</a></li>
<li><a href="http://www.clickpopmedia.com/2008/02/07/free-vector-packs-round-2/" title="Free Vector Packs: Round 2">Free Vector Packs: Round 2 (0)</a></li>
<li><a href="http://www.clickpopmedia.com/2008/04/10/free-vector-laurels/" title="Free Vector - Laurels">Free Vector - Laurels (4)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.clickpopmedia.com/2008/06/25/easy-keyboard-controls-and-game-design/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How To Make A Spraypaint Panel</title>
		<link>http://www.clickpopmedia.com/2008/06/24/how-to-make-a-spraypaint-panel/</link>
		<comments>http://www.clickpopmedia.com/2008/06/24/how-to-make-a-spraypaint-panel/#comments</comments>
		<pubDate>Tue, 24 Jun 2008 20:21:48 +0000</pubDate>
		<dc:creator>Weese</dc:creator>
		
		<category><![CDATA[DIY]]></category>

		<category><![CDATA[Free]]></category>

		<category><![CDATA[Just for Fun!]]></category>

		<category><![CDATA[Paintings]]></category>

		<category><![CDATA[Weese]]></category>

		<category><![CDATA[art]]></category>

		<category><![CDATA[Graffiti Canvas]]></category>

		<category><![CDATA[Pauls Panel]]></category>

		<category><![CDATA[Spraypaint Panels]]></category>

		<guid isPermaLink="false">http://www.clickpopmedia.com/?p=342</guid>
		<description><![CDATA[
So over the past two months I&#8217;ve been painting these Panels of VQ&#8217;s Vectors.  [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://www.clickpopmedia.com/wp-content/uploads/2008/06/four_panels1.jpg"><img class="size-medium wp-image-349" title="four_panels1" src="http://www.clickpopmedia.com/wp-content/uploads/2008/06/four_panels1-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p>So over the past two months I&#8217;ve been painting these Panels of VQ&#8217;s <a href="http://www.clickpopmedia.com/this_is_free/" target="_blank">Vectors</a>.  That got the boys and I over at ClickPop talking about how it was time to teach you how to create them too.  It&#8217;s pretty simple, all you&#8217;ll need is:<span id="more-342"></span></p>
<p>-Panel, which can purchased online or at your local arts and craft store (Michaels, A.C. Moore, etc.)</p>
<p>-A can(s) of spray paint</p>
<p>-Black Chisel Tip marker (I prefer Grand &amp; Toy, or Sharpie).</p>
<p>Below is just a shot of my panel.</p>
<p style="text-align: center;"><a href="http://www.clickpopmedia.com/wp-content/uploads/2008/06/step1.jpg"><img class="size-full wp-image-341" title="step1" src="http://www.clickpopmedia.com/wp-content/uploads/2008/06/step1.jpg" alt="" width="500" height="374" /></a></p>
<p>Next you&#8217;re going to sketch out your drawing with a regular black marker, I used a sharpie for this part.  My inspiration for this panel is from VQ&#8217;s <a href="http://weare.clickpopmedia.com/author/paul/" target="_blank">vector of Paul</a> and his <a href="http://www.clickpopmedia.com/2008/03/20/nuclear-warning-vectors/" target="_blank">Nuclear Warning</a> vector</p>
<p style="text-align: center;"><a href="http://www.clickpopmedia.com/wp-content/uploads/2008/06/step2.jpg"><img class="size-full wp-image-343" title="step2" src="http://www.clickpopmedia.com/wp-content/uploads/2008/06/step2.jpg" alt="" width="500" height="374" /></a></p>
<p>Next, go over your initial sketch with your Chisel Tipped Marker (Grand &amp; Toy seem to work really well for this).  Make sure your perimeter lines are at least the width of your chisel tip.</p>
<p style="text-align: center;"><a href="http://www.clickpopmedia.com/wp-content/uploads/2008/06/step3.jpg"><img class="size-full wp-image-344" title="step3" src="http://www.clickpopmedia.com/wp-content/uploads/2008/06/step3.jpg" alt="" width="500" height="374" /></a></p>
<p>Now, grab your can of spray, and work from the outside of the canvas inward.  Your paint is going to start drying before you finish painting the whole canvas, so be looking for any white that might come through.  Be sure to get even lines.  If you spray over your drawing, don&#8217;t worry about it, actually you can get some cool cell-shading effects by going over the lines a little.</p>
<p style="text-align: center;"><a href="http://www.clickpopmedia.com/wp-content/uploads/2008/06/step4.jpg"><img class="size-full wp-image-345" title="step4" src="http://www.clickpopmedia.com/wp-content/uploads/2008/06/step4.jpg" alt="" width="500" height="374" /></a></p>
<p>Finish spraying the whole canvas.  Let it dry for about 20 minutes (if your location is colder it may take longer).</p>
<p style="text-align: center;"><a href="http://www.clickpopmedia.com/wp-content/uploads/2008/06/step5.jpg"><img class="size-full wp-image-346" title="step5" src="http://www.clickpopmedia.com/wp-content/uploads/2008/06/step5.jpg" alt="" width="500" height="374" /></a></p>
<p>Then take your canvas and go over all of your lines again with your Chisel Tipped Marker.</p>
<p style="text-align: center;"><a href="http://www.clickpopmedia.com/wp-content/uploads/2008/06/100_2178.jpg"><img class="size-full wp-image-348" title="100_2178" src="http://www.clickpopmedia.com/wp-content/uploads/2008/06/100_2178.jpg" alt="" width="500" height="375" /></a></p>
<p>And then you&#8217;re done!  Below is all four panels for the ClickPop Office.  If you end up making millions on your panels, be sure to let me know.  Enjoy!  God bless you guys.   -Weese</p>
<p style="text-align: center;"><a href="http://www.clickpopmedia.com/wp-content/uploads/2008/06/four_panels.jpg"><img class="size-full wp-image-347" title="four_panels" src="http://www.clickpopmedia.com/wp-content/uploads/2008/06/four_panels.jpg" alt="" width="500" height="375" /></a></p>
<h3>Related Posts</h3>
<ul class="related_post">
<li><a href="http://www.clickpopmedia.com/2008/04/02/a-good-ideacontinued/" title="A Good Idea&#8230;continued">A Good Idea&#8230;continued (0)</a></li>
<li><a href="http://www.clickpopmedia.com/2008/02/26/the-brand-new-super-fantastic-2008-clickpop-lineup-and-a-vector-megaphone/" title="The ClickPopLineup (&#038; a vector megaphone)">The ClickPopLineup (&#038; a vector megaphone) (5)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.clickpopmedia.com/2008/06/24/how-to-make-a-spraypaint-panel/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Water Buffalo Skull Vector</title>
		<link>http://www.clickpopmedia.com/2008/06/18/water-buffalo-skull-vector/</link>
		<comments>http://www.clickpopmedia.com/2008/06/18/water-buffalo-skull-vector/#comments</comments>
		<pubDate>Wed, 18 Jun 2008 15:43:52 +0000</pubDate>
		<dc:creator>VQ</dc:creator>
		
		<category><![CDATA[Download]]></category>

		<category><![CDATA[Free]]></category>

		<category><![CDATA[Products]]></category>

		<category><![CDATA[VQ]]></category>

		<category><![CDATA[Vector]]></category>

		<category><![CDATA[freebies]]></category>

		<guid isPermaLink="false">http://www.clickpopmedia.com/?p=336</guid>
		<description><![CDATA[
Howdy pardners. I&#8217;m glad you stopped by the ol&#8217; ClickPop Ranch. Sit down, rest your [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="alignnone size-full wp-image-337" title="skull" src="http://www.clickpopmedia.com/wp-content/uploads/2008/06/skull.png" alt="" width="244" height="300" /></p>
<p>Howdy pardners. I&#8217;m glad you stopped by the ol&#8217; ClickPop Ranch. Sit down, rest your feet a spell, and enjoy this water buffalo skull vector. I realize that this probably isn&#8217;t the way a water buffalo rancher would write. It&#8217;s more like a regular buffalo rancher, but hey, it gets the job done.</p>
<p style="text-align: center;"><a href="http://www.clickpopmedia.com/Freebies/cowskull.zip">Download the Water Buffalo Skull Vector (.ai and .eps)</a></p>
<p style="text-align: left;"><strong>GodBless:VQ</strong></p>
<h3>Related Posts</h3>
<ul class="related_post">
<li><a href="http://www.clickpopmedia.com/2008/04/10/free-vector-laurels/" title="Free Vector - Laurels">Free Vector - Laurels (4)</a></li>
<li><a href="http://www.clickpopmedia.com/2008/06/05/batik-is-beautiful/" title="Batik is Beautiful - Free Vector Swatches UPDATED">Batik is Beautiful - Free Vector Swatches UPDATED (15)</a></li>
<li><a href="http://www.clickpopmedia.com/2008/05/19/free-vectors-penguins/" title="Free Vectors: Penguins!">Free Vectors: Penguins! (3)</a></li>
<li><a href="http://www.clickpopmedia.com/2008/04/21/free-vectors-speech-bubbles/" title="Free Vectors: Speech Bubbles">Free Vectors: Speech Bubbles (4)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.clickpopmedia.com/2008/06/18/water-buffalo-skull-vector/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Batik Photoshop Patterns</title>
		<link>http://www.clickpopmedia.com/2008/06/11/batik-photoshop-patterns/</link>
		<comments>http://www.clickpopmedia.com/2008/06/11/batik-photoshop-patterns/#comments</comments>
		<pubDate>Thu, 12 Jun 2008 02:19:46 +0000</pubDate>
		<dc:creator>VQ</dc:creator>
		
		<category><![CDATA[Download]]></category>

		<category><![CDATA[Free]]></category>

		<category><![CDATA[Products]]></category>

		<category><![CDATA[Textures]]></category>

		<category><![CDATA[VQ]]></category>

		<category><![CDATA[photoshop]]></category>

		<category><![CDATA[batik]]></category>

		<category><![CDATA[fabric]]></category>

		<category><![CDATA[texture]]></category>

		<guid isPermaLink="false">http://www.clickpopmedia.com/?p=334</guid>
		<description><![CDATA[
Last week we gave out some free Batik vectors. In that post, I mentioned that [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img title="Photoshop Batik Pattern" src="http://www.clickpopmedia.com/wp-content/uploads/2008/06/psheader.gif" alt="" /></p>
<p>Last week we gave out some <a href="http://www.clickpopmedia.com/2008/06/05/batik-is-beautiful/">free Batik vectors</a>. In that post, I mentioned that if anyone wanted the patterns as Photoshop patterns, I&#8217;d be glad to share them. Well, you asked, and I&#8217;ve finally come through.</p>
<p>In this pack of Photoshop patterns I have 6 different color schemes ranging from nice to WEIRD. There is a 500px wide and a 250px wide version of each pattern. Have fun my friends! Let us know if you do anything wonderful with them.</p>
<p style="text-align: center;"><strong><a href="http://www.clickpopmedia.com/Freebies/patterns/psBatik.pat">Download the Batik Photoshop Patterns (.pat)</a></strong></p>
<p style="text-align: center;"><strong><a href="http://www.clickpopmedia.com/Freebies/patterns/psBatik.zip">Download the Batik Photoshop Patterns (.png)</a></strong></p>
<p><strong>GodBless:VQ</strong><br />
<h3>Related Posts</h3>
<ul class="related_post">
<li><a href="http://www.clickpopmedia.com/2008/06/05/batik-is-beautiful/" title="Batik is Beautiful - Free Vector Swatches UPDATED">Batik is Beautiful - Free Vector Swatches UPDATED (15)</a></li>
<li><a href="http://www.clickpopmedia.com/2008/06/02/free-brick-textures/" title="Free Brick Textures">Free Brick Textures (0)</a></li>
<li><a href="http://www.clickpopmedia.com/2008/04/30/photoshop-watercolor-paint-smudges/" title="Photoshop Watercolor Paint Smudges">Photoshop Watercolor Paint Smudges (0)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.clickpopmedia.com/2008/06/11/batik-photoshop-patterns/feed/</wfw:commentRss>
		</item>
		<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 [...]]]></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><br />
<h3>Related Posts</h3>
<ul class="related_post">
<li><a href="http://www.clickpopmedia.com/2008/05/28/cool-rollover-effects-with-filters/" title="Cool Rollover Effects with Filters">Cool Rollover Effects with Filters (6)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.clickpopmedia.com/2008/06/11/realistic-shadow-effects-using-filters/feed/</wfw:commentRss>
		</item>
		<item>
		<title>A CSS/JavaScript HORIZONTAL Accordion</title>
		<link>http://www.clickpopmedia.com/2008/06/05/a-cssjavascript-horizontal-accordion/</link>
		<comments>http://www.clickpopmedia.com/2008/06/05/a-cssjavascript-horizontal-accordion/#comments</comments>
		<pubDate>Thu, 05 Jun 2008 17:45:41 +0000</pubDate>
		<dc:creator>§ean</dc:creator>
		
		<category><![CDATA[Sean]]></category>

		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[accordion]]></category>

		<category><![CDATA[css]]></category>

		<category><![CDATA[horizontal]]></category>

		<guid isPermaLink="false">http://www.clickpopmedia.com/?p=328</guid>
		<description><![CDATA[Accordions are great, but sometimes a big pain to setup.  Mootools, and several other [...]]]></description>
			<content:encoded><![CDATA[<p>Accordions are great, but sometimes a big pain to setup.  <a title="MooTools" href="http://www.mootools.net" target="_blank">Mootools</a>, and several other libraries, offer great pre-built accordion systems, but they&#8217;ve got their issues.  We recently tried using mootools accordion on a client&#8217;s website, but we were having a fair amount of browser compatibility problems, so we set out in search for a better solution.  The nice people at <a title="Switch on the Code" href="http://www.switchonthecode.com" target="_blank">Switch on the Code</a> wrote a nice tutorial on how to build your own <a title="Javascript and CSS Tutorial - Accordion Menus" href="http://blog.paranoidferret.com/index.php/2007/10/22/javascript-and-css-tutorial-accordion-menus/" target="_blank">CSS/Javascript accordion</a>.  Needless to say, it suited our needs perfectly. Then I thought to myself, wouldn&#8217;t it be great if someone made a HORIZONTAL accordion using a similar method.</p>
<p><iframe src="http://www.clickpopmedia.com/sean_tutorials/horizontal_accordion/horizontal_accordion.htm" style="width:650px;height:300px;border:none;"></iframe></p>
<p><span id="more-328"></span>Today we are going to do something that is important for any developer, examine code.  The ability to read another person&#8217;s code is vital if you want to be successful.  Obviously everyone does things differently, and it&#8217;s easy to get into thinking that you have to do everything from scratch, but sometimes you are just going to have to use a prebuilt element. As a lesson, we will be taking a look at the Accordion Code from Switch on the Code and turn it in to a horizontal accordion.</p>
<p>We&#8217;ll start first with the HTML</p>
<p>Switch on the Code provides with this:</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="sc3"><span class="re1">&lt;div</span> <span class="re0">id</span>=<span class="st0">&quot;AccordionContainer&quot;</span> <span class="re0">class</span>=<span class="st0">&quot;AccordionContainer&quot;</span><span class="re2">&gt;</span></span><br />
<span class="sc3"><span class="re1">&lt;div</span> <span class="re0">onclick</span>=<span class="st0">&quot;runAccordion(1);&quot;</span><span class="re2">&gt;</span></span><br />
<span class="sc3"><span class="re1">&lt;div</span> <span class="re0">class</span>=<span class="st0">&quot;AccordionTitle&quot;</span><span class="re2">&gt;</span></span><br />
&nbsp; &nbsp; Accordion 1<span class="sc3"><span class="re1">&lt;/div<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;/div<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;div</span> <span class="re0">id</span>=<span class="st0">&quot;Accordion1Content&quot;</span> <span class="re0">class</span>=<span class="st0">&quot;AccordionContent&quot;</span><span class="re2">&gt;</span></span><br />
&nbsp; I Am Accordion 1.<span class="sc3"><span class="re1">&lt;/div<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;div</span> <span class="re0">onclick</span>=<span class="st0">&quot;runAccordion(2);&quot;</span><span class="re2">&gt;</span></span><br />
<span class="sc3"><span class="re1">&lt;div</span> <span class="re0">class</span>=<span class="st0">&quot;AccordionTitle&quot;</span><span class="re2">&gt;</span></span><br />
&nbsp; &nbsp; Accordion 2<span class="sc3"><span class="re1">&lt;/div<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;/div<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;div</span> <span class="re0">id</span>=<span class="st0">&quot;Accordion2Content&quot;</span> <span class="re0">class</span>=<span class="st0">&quot;AccordionContent&quot;</span><span class="re2">&gt;</span></span><br />
&nbsp; I Am Accordion 2.<span class="sc3"><span class="re1">&lt;/div<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;div</span> <span class="re0">onclick</span>=<span class="st0">&quot;runAccordion(4);&quot;</span><span class="re2">&gt;</span></span><br />
<span class="sc3"><span class="re1">&lt;div</span> <span class="re0">class</span>=<span class="st0">&quot;AccordionTitle&quot;</span><span class="re2">&gt;</span></span><br />
&nbsp; &nbsp; Accordion 4<span class="sc3"><span class="re1">&lt;/div<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;/div<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;div</span> <span class="re0">id</span>=<span class="st0">&quot;Accordion4Content&quot;</span> <span class="re0">class</span>=<span class="st0">&quot;AccordionContent&quot;</span><span class="re2">&gt;</span></span><br />
&nbsp; I Am Accordion 4.<span class="sc3"><span class="re1">&lt;/div<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;div</span> <span class="re0">onclick</span>=<span class="st0">&quot;runAccordion(5);&quot;</span><span class="re2">&gt;</span></span><br />
<span class="sc3"><span class="re1">&lt;div</span> <span class="re0">class</span>=<span class="st0">&quot;AccordionTitle&quot;</span><span class="re2">&gt;</span></span><br />
&nbsp; &nbsp; Accordion 5<span class="sc3"><span class="re1">&lt;/div<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;/div<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;div</span> <span class="re0">id</span>=<span class="st0">&quot;Accordion5Content&quot;</span> <span class="re0">class</span>=<span class="st0">&quot;AccordionContent&quot;</span><span class="re2">&gt;</span></span><br />
&nbsp; I Am Accordion 5.<span class="sc3"><span class="re1">&lt;/div<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;/div<span class="re2">&gt;</span></span></span></div>
<p>This is a bit bulky for my taste, so I will be cutting down on a lot of this.  I will layout an all new structure, and I will also only use 2 accordions instead of 5&#8230; but you can use as many as you want.</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="sc3"><span class="re1">&lt;div</span> <span class="re0">class</span>=<span class="st0">&quot;Toggler&quot;</span> <span class="re0">onclick</span>=<span class="st0">&quot;runAccordion(1);&quot;</span><span class="re2">&gt;</span></span><span class="sc3"><span class="re1">&lt;img</span> <span class="re0">src</span>=<span class="st0">&quot;accordion1.png&quot;</span> <span class="re0">alt</span>=<span class="st0">&quot;&quot;</span> <span class="re2">/&gt;</span></span><span class="sc3"><span class="re1">&lt;/div<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;div</span> <span class="re0">id</span>=<span class="st0">&quot;Content1&quot;</span> <span class="re0">class</span>=<span class="st0">&quot;Content&quot;</span><span class="re2">&gt;</span></span>I Am Accordion 1.<span class="sc3"><span class="re1">&lt;/div<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;div</span> <span class="re0">class</span>=<span class="st0">&quot;Toggler&quot;</span> <span class="re0">onclick</span>=<span class="st0">&quot;runAccordion(2);&quot;</span><span class="re2">&gt;</span></span><span class="sc3"><span class="re1">&lt;img</span> <span class="re0">src</span>=<span class="st0">&quot;accordion2.png&quot;</span> <span class="re0">alt</span>=<span class="st0">&quot;&quot;</span> <span class="re2">/&gt;</span></span><span class="sc3"><span class="re1">&lt;/div<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;div</span> <span class="re0">id</span>=<span class="st0">&quot;Content2&quot;</span> <span class="re0">class</span>=<span class="st0">&quot;Content&quot;</span> <span class="re0">style</span>=<span class="st0">&quot;border-right:1px solid #333;&quot;</span><span class="re2">&gt;</span></span>I Am Accordion 2.<span class="sc3"><span class="re1">&lt;/div<span class="re2">&gt;</span></span></span></div>
<p>There, that&#8217;s better.  I have replaced the multiple divs per section with just 2 divs for each accordion section.  There is a Toggler and a Content div.  Each div is assigned the appropriate class.  Togglers are given an onclick function of runAccordion(#), where the # is replaced by the section number.  Content divs are given and id of Content# using the same principle.  You will also notice the last section is given some extra style features, this is so there will be an end border on the entire Accordion.</p>
<p>Next we&#8217;ll move on to the CSS.  We&#8217;re going to completely scrap everything they gave us, and start from scratch:</p>
<div class="dean_ch" style="white-space: wrap;"><span class="re1">.Toggler</span><br />
<span class="br0">&#123;</span><br />
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;width<span class="re2">:<span class="re3">20px</span></span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; height<span class="re2">:<span class="re3">200px</span></span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; overflow<span class="re2">:hidden</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; font-family<span class="re2">:Arial</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; font-size<span class="re2">:<span class="re3">12px</span></span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; font-weight<span class="re2">:bold</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; text-align<span class="re2">:center</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; float<span class="re2">:left</span>;<br />
<span class="br0">&#125;</span><br />
<span class="re1">.Content</span><br />
<span class="br0">&#123;</span><br />
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;height<span class="re2">:<span class="re3">198px</span></span>;<br />
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;border-top<span class="re2">:<span class="re3">1px</span></span> <span class="kw2">solid</span> <span class="re0">#<span class="nu0">333</span></span>;<br />
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;border-bottom<span class="re2">:<span class="re3">1px</span></span> <span class="kw2">solid</span> <span class="re0">#<span class="nu0">333</span></span>;<br />
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">background-color</span>:<span class="re0">#ececec</span>;<br />
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;display<span class="re2">:none</span>;<br />
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;width<span class="re2">:<span class="re3">0px</span></span>;<br />
&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;float<span class="re2">:left</span>;<br />
<span class="br0">&#125;</span></div>
<p>An important thing to note here is the floats, In order to get the divs to position next to each other, they need to be floated or set to display:inline, I chose to use float.</p>
<p>Finally the Javascript:</p>
<p>I am not going to compare JavaScripts, I will just provide the modified function, and explain what changes were made.</p>
<div class="dean_ch" style="white-space: wrap;"><span class="kw2">var</span> ContentWidth = <span class="nu0">200</span>;<br />
<span class="kw2">var</span> TimeToSlide = <span class="nu0">250.0</span>;</p>
<p><span class="kw2">var</span> openAccordion = <span class="st0">&#8221;</span>;</p>
<p><span class="kw2">function</span> runAccordion<span class="br0">&#40;</span>index<span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; <span class="kw2">var</span> nID = <span class="st0">&quot;Content&quot;</span> + index;<br />
&nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>openAccordion == nID<span class="br0">&#41;</span><br />
&nbsp; &nbsp; nID = <span class="st0">&#8221;</span>;</p>
<p>&nbsp; setTimeout<span class="br0">&#40;</span><span class="st0">&quot;animate(&quot;</span> + <span class="kw2">new</span> Date<span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">getTime</span><span class="br0">&#40;</span><span class="br0">&#41;</span> + <span class="st0">&quot;,&quot;</span> + TimeToSlide + <span class="st0">&quot;,&#8217;&quot;</span> + openAccordion + <span class="st0">&quot;&#8217;,'&quot;</span> + nID + <span class="st0">&quot;&#8217;)&quot;</span>, <span class="nu0">33</span><span class="br0">&#41;</span>;</p>
<p>&nbsp; openAccordion = nID;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw2">function</span> animate<span class="br0">&#40;</span>lastTick, timeLeft, closingId, openingId<span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; <span class="kw2">var</span> curTick = <span class="kw2">new</span> Date<span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">getTime</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; <span class="kw2">var</span> elapsedTicks = curTick - lastTick;</p>
<p>&nbsp; <span class="kw2">var</span> opening = <span class="br0">&#40;</span>openingId == <span class="st0">&#8221;</span><span class="br0">&#41;</span> ? <span class="kw2">null</span> : document.<span class="me1">getElementById</span><span class="br0">&#40;</span>openingId<span class="br0">&#41;</span>;<br />
&nbsp; <span class="kw2">var</span> closing = <span class="br0">&#40;</span>closingId == <span class="st0">&#8221;</span><span class="br0">&#41;</span> ? <span class="kw2">null</span> : document.<span class="me1">getElementById</span><span class="br0">&#40;</span>closingId<span class="br0">&#41;</span>;</p>
<p>&nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>timeLeft &lt;= elapsedTicks<span class="br0">&#41;</span><br />
&nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>opening != <span class="kw2">null</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; opening.<span class="me1">style</span>.<span class="me1">width</span> = ContentWidth + <span class="st0">&#8216;px&#8217;</span>;</p>
<p>&nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>closing != <span class="kw2">null</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; closing.<span class="me1">style</span>.<span class="me1">display</span> = <span class="st0">&#8216;none&#8217;</span>;<br />
&nbsp; &nbsp; &nbsp; closing.<span class="me1">style</span>.<span class="me1">width</span> = <span class="st0">&#8216;0px&#8217;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="kw1">return</span>;<br />
&nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; timeLeft -= elapsedTicks;<br />
&nbsp; <span class="kw2">var</span> newClosedWidth = Math.<span class="me1">round</span><span class="br0">&#40;</span><span class="br0">&#40;</span>timeLeft/TimeToSlide<span class="br0">&#41;</span> * ContentWidth<span class="br0">&#41;</span>;</p>
<p>&nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>opening != <span class="kw2">null</span><span class="br0">&#41;</span><br />
&nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>opening.<span class="me1">style</span>.<span class="me1">display</span> != <span class="st0">&#8216;block&#8217;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; opening.<span class="me1">style</span>.<span class="me1">display</span> = <span class="st0">&#8216;block&#8217;</span>;<br />
&nbsp; &nbsp; opening.<span class="me1">style</span>.<span class="me1">width</span> = <span class="br0">&#40;</span>ContentWidth - newClosedWidth<span class="br0">&#41;</span> + <span class="st0">&#8216;px&#8217;</span>;<br />
&nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>closing != <span class="kw2">null</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; closing.<span class="me1">style</span>.<span class="me1">width</span> = newClosedWidth + <span class="st0">&#8216;px&#8217;</span>;</p>
<p>&nbsp; setTimeout<span class="br0">&#40;</span><span class="st0">&quot;animate(&quot;</span> + curTick + <span class="st0">&quot;,&quot;</span> + timeLeft +<span class="st0">&quot;,&#8217;&quot;</span> + closingId + <span class="st0">&quot;&#8217;,'&quot;</span> + openingId + <span class="st0">&quot;&#8217;)&quot;</span>, <span class="nu0">33</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></div>
<p>Now get ready for this, these are some monstrous changes!!  I mean seriously&#8230; not for the faint of heart.  The first thing I did of course was read through the code&#8230; then I read it again&#8230; and 3rd time just for good measure.  Then I opened up Find/Replace, and replaced the word <strong>height</strong> with the word <strong>width</strong> everywhere in the code.  I of course maintained capitalization where it was.  </p>
<p>Then I changed one other line of code:</p>
<p><strong>var nID = &#8220;Content&#8221; + index;</strong></p>
<p>This was originally:</p>
<p><strong>var nID = &#8220;Accordion&#8221; + index + &#8220;Content&#8221;;</strong></p>
<p>Since I changed the Content divs id tags to just Content#, I needed to change this line of code accordingly.  Like I said, I read through the code over and over.  Just to make sure everything was correct.  I could sit here and explain everything that the function does, but who really wants to read all of that when you can spend time playing with the accordion!</p>
<p>Two other important things to note:  At the top of the JavaScript, the two variables control the width that the content divs will expand to, and the amount of time in milliseconds that the animation will take.<br />
<h3>Related Posts</h3>
<ul class="related_post">
<li><a href="http://www.clickpopmedia.com/2008/05/05/twitter-feeds-made-simple/" title="Twitter feeds made simple.">Twitter feeds made simple. (0)</a></li>
<li><a href="http://www.clickpopmedia.com/2008/03/12/ajax-and-php-getting-data-on-the-fly/" title="AJAX and PHP, getting data on the fly.">AJAX and PHP, getting data on the fly. (1)</a></li>
<li><a href="http://www.clickpopmedia.com/2008/03/04/intro-to-website-dynamics/" title="Geek Time - Binary Clock">Geek Time - Binary Clock (0)</a></li>
<li><a href="http://www.clickpopmedia.com/2008/02/19/weekly-snip-o-codes/" title="Weekly Snip-O-Codes!">Weekly Snip-O-Codes! (0)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.clickpopmedia.com/2008/06/05/a-cssjavascript-horizontal-accordion/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Batik is Beautiful - Free Vector Swatches UPDATED</title>
		<link>http://www.clickpopmedia.com/2008/06/05/batik-is-beautiful/</link>
		<comments>http://www.clickpopmedia.com/2008/06/05/batik-is-beautiful/#comments</comments>
		<pubDate>Thu, 05 Jun 2008 05:07:28 +0000</pubDate>
		<dc:creator>VQ</dc:creator>
		
		<category><![CDATA[Download]]></category>

		<category><![CDATA[Free]]></category>

		<category><![CDATA[Products]]></category>

		<category><![CDATA[Textures]]></category>

		<category><![CDATA[VQ]]></category>

		<category><![CDATA[Vector]]></category>

		<category><![CDATA[batik]]></category>

		<category><![CDATA[fabric]]></category>

		<category><![CDATA[freebies]]></category>

		<category><![CDATA[swatches]]></category>

		<guid isPermaLink="false">http://www.clickpopmedia.com/?p=325</guid>
		<description><![CDATA[
Last week I posted some desktop wallpaper of a new vector swatch I was working [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="alignnone size-full wp-image-326 aligncenter" title="indonesian batik header" src="http://www.clickpopmedia.com/wp-content/uploads/2008/06/header.jpg" alt="" /></p>
<p>Last week I posted some <a href="http://www.clickpopmedia.com/2008/05/29/some-wallpaper/">desktop wallpaper</a> of a new vector swatch I was working on. Well, the pattern is finally finished, and I&#8217;m pretty happy with it. The design is based on a beautiful Indonesian batik fabric I saw and couldn&#8217;t get out of my mind. It&#8217;s exotic, a little trippy, and a lot of fun to play around with.</p>
<p><img style="float: left;" title="batik swatches" src="http://www.clickpopmedia.com/wp-content/uploads/2008/06/swatch_thumbs.gif" alt="" /></p>
<p>I set up three different color schemes: a regal orange and blue, an electric yellow and blue, and a psychedelic green and pink. I also made a bunch of Photoshop patterns from this swatch, if anyone wants those, let me know and I&#8217;ll post them.</p>
<blockquote><p><strong>Batik (<a href="http://en.wikipedia.org/wiki/Batik"><em>from wikipedia.com</em></a><em>, emphasis mine</em>)</strong></p>
<p>a wax-resist dyeing technique used on textile. Batik is found in several countries of West Africa, such as Nigeria, Ghana, Cameroon and Mali, and in Asia, such as India, Sri Lanka, Bangladesh, Iran, the Philippines, Malaysia and Thailand. However, it is in Indonesia that it is considered a national art form.</p></blockquote>
<p style="text-align: center;"><strong><a href="http://www.clickpopmedia.com/Freebies/batik.zip">Download the Batik Vector Swatch (.ai and Illustrator swatches)</a></strong></p>
<p style="text-align: left;"><strong>Update: </strong>First, the Batik vectors have been updated to fix a few issues with the patterns and include two more color schemes. We&#8217;ve also released some <a href="http://www.clickpopmedia.com/2008/06/11/batik-photoshop-patterns/">Photoshop patterns of these swatches</a>.</p>
<p style="text-align: left;">If you come up with some cool color schemes, we&#8217;d be excited to see them.</p>
<p style="text-align: left;"><strong>GodBless:VQ</strong></p>
<p style="clear: both; text-align: left;">.</p>
<h3>Related Posts</h3>
<ul class="related_post">
<li><a href="http://www.clickpopmedia.com/2008/06/18/water-buffalo-skull-vector/" title="Water Buffalo Skull Vector">Water Buffalo Skull Vector (0)</a></li>
<li><a href="http://www.clickpopmedia.com/2008/06/11/batik-photoshop-patterns/" title="Batik Photoshop Patterns">Batik Photoshop Patterns (5)</a></li>
<li><a href="http://www.clickpopmedia.com/2008/05/19/free-vectors-penguins/" title="Free Vectors: Penguins!">Free Vectors: Penguins! (3)</a></li>
<li><a href="http://www.clickpopmedia.com/2008/04/24/free-waves-and-ridges-illustrator-swatches/" title="Free! Waves and Ridges Illustrator Swatches">Free! Waves and Ridges Illustrator Swatches (1)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.clickpopmedia.com/2008/06/05/batik-is-beautiful/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Free Brick Textures</title>
		<link>http://www.clickpopmedia.com/2008/06/02/free-brick-textures/</link>
		<comments>http://www.clickpopmedia.com/2008/06/02/free-brick-textures/#comments</comments>
		<pubDate>Tue, 03 Jun 2008 00:49:05 +0000</pubDate>
		<dc:creator>VQ</dc:creator>
		
		<category><![CDATA[Download]]></category>

		<category><![CDATA[Free]]></category>

		<category><![CDATA[Products]]></category>

		<category><![CDATA[Textures]]></category>

		<category><![CDATA[VQ]]></category>

		<category><![CDATA[brick]]></category>

		<category><![CDATA[freebies]]></category>

		<category><![CDATA[texture]]></category>

		<guid isPermaLink="false">http://www.clickpopmedia.com/?p=323</guid>
		<description><![CDATA[In case you didn&#8217;t know, we&#8217;re all designers or developers at ClickPop. As such, we&#8217;re [...]]]></description>
			<content:encoded><![CDATA[<p>In case you didn&#8217;t know, we&#8217;re all designers or developers at ClickPop. As such, we&#8217;re always looking for great stuff to help with our designs. Recently, <a href="http://www.clickpopmedia.com/author/weese/">Weese</a> and I were in need of some textures of different types. So we set off on a quest around town to find the most splendid textures our neighborhood has to offer.</p>
<p>We managed to get some really useful textures, and we thought you might be able to use some of them as well. This week we have a bunch of brick textures. Let us know if you liked these, and would be interested in some of the other textures we amassed. Four more textures and a link to the zip are after the jump.</p>
<h3>Moldy Brick</h3>
<p style="text-align: center;"><a href="http://www.clickpopmedia.com/Freebies/textures/brick/moldy_brick.jpg"><img class="alignnone aligncenter" src="http://www.clickpopmedia.com/Freebies/textures/brick/moldy_brickThumb.jpg" alt="" /></a></p>
<p style="text-align: center;"><span id="more-323"></span></p>
<h3>Old Brick</h3>
<p style="text-align: center;"><a href="http://www.clickpopmedia.com/Freebies/textures/brick/old_brick.jpg"><img class="alignnone aligncenter" src="http://www.clickpopmedia.com/Freebies/textures/brick/old_brickThumb.jpg" alt="" /></a></p>
<h3>Fake Red Brick</h3>
<p style="text-align: center;"><a href="http://www.clickpopmedia.com/Freebies/textures/brick/fake_red_brick.jpg"><img class="alignnone aligncenter" src="http://www.clickpopmedia.com/Freebies/textures/brick/fake_red_brickThumb.jpg" alt="" /></a></p>
<h3>Old Brick and Stone</h3>
<p style="text-align: center;"><a href="http://www.clickpopmedia.com/Freebies/textures/brick/old_brick_and_stone.jpg"><img class="alignnone aligncenter" src="http://www.clickpopmedia.com/Freebies/textures/brick/old_brick_and_stoneThumb.jpg" alt="" /></a></p>
<h3>Brick</h3>
<p style="text-align: center;"><a href="http://www.clickpopmedia.com/Freebies/textures/brick/brick.jpg"><img class="alignnone aligncenter" src="http://www.clickpopmedia.com/Freebies/textures/brick/brickThumb.jpg" alt="" /></a></p>
<p style="text-align: center;"><strong><a href="http://www.clickpopmedia.com/Freebies/textures/brick.zip">Download All the Brick Textures (.zip)</a></strong></p>
<p style="text-align: left;"><strong>GodBless:VQ</strong></p>
<h3>Related Posts</h3>
<ul class="related_post">
<li><a href="http://www.clickpopmedia.com/2008/06/18/water-buffalo-skull-vector/" title="Water Buffalo Skull Vector">Water Buffalo Skull Vector (0)</a></li>
<li><a href="http://www.clickpopmedia.com/2008/06/11/batik-photoshop-patterns/" title="Batik Photoshop Patterns">Batik Photoshop Patterns (5)</a></li>
<li><a href="http://www.clickpopmedia.com/2008/06/05/batik-is-beautiful/" title="Batik is Beautiful - Free Vector Swatches UPDATED">Batik is Beautiful - Free Vector Swatches UPDATED (15)</a></li>
<li><a href="http://www.clickpopmedia.com/2008/05/29/some-wallpaper/" title="Indonesian Batik Wallpaper">Indonesian Batik Wallpaper (4)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.clickpopmedia.com/2008/06/02/free-brick-textures/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Indonesian Batik Wallpaper</title>
		<link>http://www.clickpopmedia.com/2008/05/29/some-wallpaper/</link>
		<comments>http://www.clickpopmedia.com/2008/05/29/some-wallpaper/#comments</comments>
		<pubDate>Thu, 29 May 2008 15:10:53 +0000</pubDate>
		<dc:creator>VQ</dc:creator>
		
		<category><![CDATA[Download]]></category>

		<category><![CDATA[Free]]></category>

		<category><![CDATA[Products]]></category>

		<category><![CDATA[VQ]]></category>

		<category><![CDATA[freebies]]></category>

		<category><![CDATA[wallpaper]]></category>

		<guid isPermaLink="false">http://www.clickpopmedia.com/?p=322</guid>
		<description><![CDATA[
I&#8217;m finishing up a cool vector swatch based on a beautiful Indonesian batik. In anticipation [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img title="Batik" src="http://www.clickpopmedia.com/wp-content/uploads/2008/05/webheader.gif" alt="" /></p>
<p>I&#8217;m finishing up a cool vector swatch based on a beautiful Indonesian batik. In anticipation of that freebie, I wanted to offer another one, our first wallpaper offering. Keep in mind, although the pattern is quite nice, it can get a little hard on the eyes. I hope you enjoy them.</p>
<p style="text-align: center;"><img class="alignnone size-full title=" src="http://www.clickpopmedia.com/wp-content/uploads/2008/05/thumbnail.jpg" alt="" /><br />
<a href="http://www.clickpopmedia.com/Freebies/wallpaper/ClickPop1024px.jpg" target="_blank">1024&#215;768 Wallpaper</a> |  <a href="http://www.clickpopmedia.com/Freebies/wallpaper/ClickPop1440px.jpg">1440&#215;900 Wallpaper</a></p>
<p><strong>GodBless:VQ</strong><br />
<h3>Related Posts</h3>
<ul class="related_post">
<li><a href="http://www.clickpopmedia.com/2008/06/18/water-buffalo-skull-vector/" title="Water Buffalo Skull Vector">Water Buffalo Skull Vector (0)</a></li>
<li><a href="http://www.clickpopmedia.com/2008/06/05/batik-is-beautiful/" title="Batik is Beautiful - Free Vector Swatches UPDATED">Batik is Beautiful - Free Vector Swatches UPDATED (15)</a></li>
<li><a href="http://www.clickpopmedia.com/2008/06/02/free-brick-textures/" title="Free Brick Textures">Free Brick Textures (0)</a></li>
<li><a href="http://www.clickpopmedia.com/2008/05/19/free-vectors-penguins/" title="Free Vectors: Penguins!">Free Vectors: Penguins! (3)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.clickpopmedia.com/2008/05/29/some-wallpaper/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
<br />
<b>Warning</b>:  stristr() [<a href='function.stristr'>function.stristr</a>]: Empty delimiter in <b>/home/vmnstudi/public_html/wp-content/plugins/wassup/wassup.php</b> on line <b>2093</b><br />
