<?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>Orange Splotch</title>
	<atom:link href="http://orangesplotch.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://orangesplotch.com</link>
	<description>Web developing in the middle of the night.</description>
	<lastBuildDate>Sun, 06 Jan 2013 06:30:39 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Orange is back</title>
		<link>http://orangesplotch.com/orange-is-back/</link>
		<comments>http://orangesplotch.com/orange-is-back/#comments</comments>
		<pubDate>Sun, 06 Jan 2013 06:30:39 +0000</pubDate>
		<dc:creator>mattc</dc:creator>
				<category><![CDATA[Random]]></category>
		<category><![CDATA[Site]]></category>
		<category><![CDATA[SPLoTCH]]></category>

		<guid isPermaLink="false">http://orangesplotch.com/?p=429</guid>
		<description><![CDATA[So it's been a while. And when I say a while, it looks like my last post was in 2010. That's pretty pathetic.

I've had a very eventful couple of years. But I have really missed my home here at orangesplotch. It's time to get back in the saddle and ride off into the sunrise. Yes, that's sunrise, because today is a new day. Welcome back! I've missed you all.]]></description>
				<content:encoded><![CDATA[<p>So it's been a while. And when I say a while, it looks like my last post was in 2010. That's pretty pathetic.</p>
<p>I've had a very eventful couple of years. But I have really missed my home here at orangesplotch. It's time to get back in the saddle and ride off into the sunrise. Yes, that's sunrise, because today is a new day. Welcome back! I've missed you all. Lots of great things to come: tips, tutorials, and hopefully even a site makeover.</p>
<p>To celebrate, here's a link to National Geographic's "<a href="http://photography.nationalgeographic.com/photography/photos/life-color-orange/#/orange-glass-amos_1469_600x450.jpg">Life in Color: Orange</a>". Lots of wonderful photos to show just how fantastic of a color orange is.</p>
<p>Enjoy! </p>
]]></content:encoded>
			<wfw:commentRss>http://orangesplotch.com/orange-is-back/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Web Fonts and Javascript Position Offsets</title>
		<link>http://orangesplotch.com/web-fonts-and-javascript-positions/</link>
		<comments>http://orangesplotch.com/web-fonts-and-javascript-positions/#comments</comments>
		<pubDate>Sat, 18 Dec 2010 02:12:25 +0000</pubDate>
		<dc:creator>mattc</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[callback]]></category>
		<category><![CDATA[fonts]]></category>
		<category><![CDATA[typekit]]></category>
		<category><![CDATA[web fonts]]></category>

		<guid isPermaLink="false">http://orangesplotch.com/?p=387</guid>
		<description><![CDATA[I started using Typekit's web fonts on this site and suddenly my Javascript demos weren't working right. Finally tracked it down and solved the problem using Typekit's font event callbacks. All of the juicy details of the problem and the solution are posted in this riveting article.]]></description>
				<content:encoded><![CDATA[<p>Funny things can happen to your Javascript effects when you use web fonts. Especially when you are dealing with object positions at load time. I had an issue myself installing web fonts on this site, and thought I would post the solution here in case anyone else runs into a similar problem.</p>
<p>Let me first make it clear that I am not trying to discourage developers from using web fonts. Like any web designer out there, I am very excited about the possibilities that services like <a href="http://typekit.com/">Typekit</a> have made available to the masses. No longer are we stuck with Georgia and Verdana as our only font options for every site. <strong>Web fonts are fantastic!</strong> I'm glad we cleared that up, let's move on.</p>
<h3>Moving on</h3>
<p>I recently posted a tutorial on using Javascript to make an object follow the position of the mouse. One day I noticed that in my demos the object was no longer underneath the mouse. Instead there was a gap. If I moved the demo further down on the page, the gap between the object and the mouse got bigger. What had changed to cause this offset when the page worked fine a few days earlier? I hadn't changed any of the code.</p>
<p>The answer was web fonts. But, you might ask, how could something so wonderful as web fonts do something so horrible as breaking all of your innocent Javascript math? Whether or not you are actually asking that, I'll give you the answer. It was actually pretty obvious once I sat down and worked it out.  So here you go &mdash;</p>
<h3>Web fonts breaking DOM object positions explained</h3>
<p>The code I used to store the object positions was executed on the DOM load event. Technically this is the moment that the browser has loaded its content and rendered the page. This is when all of the object positions are supposed to be final. <em>Except</em> that when using web fonts, the page isn't finished rendering yet. </p>
<p>Web font loading happens after the DOM has completed loading. Once the fonts have finished loading, the text is re-rendered using the downloaded fonts. This is why on some sites you see the text shift around shortly after the page has loaded.</p>
<p>Since I was getting object positions before the fonts were loaded, the positions I saved were not valid. They were not the positions of the objects once the fonts were loaded and the text had finished moving. And because the shifting gets larger the further down the text you go, the offsets in my demo were bigger the further down the page I placed it.</p>
<h3>So what is the solution?</h3>
<p>Well one way to fix it would be to continuously get the object positions. This way the position you have will always be correct. The problem is that constantly polling the browser for current object positions places an unnecessary load on the browser and can slow your scripts.</p>
<p>Thanks to the hard-working guys at Typekit, there is a better way. Instead of constantly polling for the current positions and offsets, you only have to get them once, right after the web fonts have finished rendering and all of the object positions are final. Typekit makes this easy with its <a title="Typekit font events" href="http://blog.typekit.com/2010/11/11/font-events-using-javascript-callbacks/">font event callbacks</a>.</p>
<p>To fix my demos, I simply added an event handler that updates the object positions once the web fonts are rendered. I've included a snippet of the code so you can see how it works. </p>
<pre>// Javascript to execute when fonts become active
try {
  Typekit.load({
    active: function() {
      offset1 = $('#mouse-position-demo').offset();
      offset2 = $('#mouse_follower_demo').offset();
    }
  })
} catch(e) {}
</pre>
<p>For more info on these events and other things you can do with them, read <a title="Typekit font events" href="http://blog.typekit.com/2010/11/11/font-events-using-javascript-callbacks/">Typekit's article discussing their callbacks</a>. If anyone has their own tips in using Javascript and web fonts together, please post them in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://orangesplotch.com/web-fonts-and-javascript-positions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mouse Follower – Javascript Tutorial</title>
		<link>http://orangesplotch.com/mouse_follower-javascript_tutorial/</link>
		<comments>http://orangesplotch.com/mouse_follower-javascript_tutorial/#comments</comments>
		<pubDate>Mon, 13 Dec 2010 13:51:26 +0000</pubDate>
		<dc:creator>mattc</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Animation]]></category>
		<category><![CDATA[follower]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[mouse]]></category>
		<category><![CDATA[timer]]></category>

		<guid isPermaLink="false">http://orangesplotch.com/?p=357</guid>
		<description><![CDATA[Make an HTML object (such as an image) follow the mouse around the page using Javascript.]]></description>
				<content:encoded><![CDATA[<p class="synopsis">
In this tutorial, we will make an object follow the mouse using Javascript. This is similar to the startDrag command in Flash that some of you may be familiar with. It is a fairly simple effect and will be a good starting point for this Javascript animation tutorial series.
</p>
<h3>Setup</h3>
<p>
This tutorial is going to focus on a div (the "stage") and an image inside it (the "follower"). With Javascript we will make the "follower" follow the mouse inside the "stage".
</p>
<p>
To make things easy, I am using the jQuery Javascript library. For those who aren't familiar with jQuery, it is a Javascript library that simplifies cross browser scripting by creating a set of common commands for doing common tasks. Feel free to use whatever Javascript library you prefer. While the syntax may be different, the principals we'll use in this tutorial can be applied to any of the common Javascript libraries.
</p>
<h3>Getting the mouse position</h3>
<p>
The first thing to do is to track the mouse. Using jQuery, we create a mouse move event listener. An event listener is a function that is executed every time an event happens. Every time the user moves the mouse, this listener will capture its new position.</p>
<p>Notice the <code>e</code> in the following code. That is the event object and in jQuery, mouse events have a <code>pageX</code> and <code>pageY</code> property that represents the position of the mouse on the page. So far it's pretty simple.</p>
<pre class="code javascript">
// track and save the position of the mouse
$(document).mousemove( function(e) {
  mouseX = e.pageX;
  mouseY = e.pageY; } );
</pre>
<p>
Now we want to be moving our image around inside of our "stage" div only. So we'll need to convert the mouse position, which is given in terms of the full page, to be in reference to the "stage". So here is the additional code to get the relative mouse positions.
</p>
<pre class="code javascript">
// get the stage offset relative to the page
$(document).ready( function () {
  offset = $('#stage').offset();
} );

// track and save the position of the mouse
$(document).mousemove( function(e) {
  mouseX = e.pageX;
  mouseY = e.pageY;
  relMouseX = mouseX - offset.left;
  relMouseY = mouseY - offset.top;
} );
</pre>
<p>
The box below shows the difference between the relative positions and the absolute position.
</p>
<div class="demo">
<div class="stage" id="mouse-position-demo">
<div class="trace">
	<span class="label">mouseX: </span><span class="value" id="mouse_x-trace">0</span>	<span class="label">mouseY: </span><span class="value" id="mouse_y-trace">0</span>
</div>
<div class="trace">
	<span class="label">relMouseX: </span><span class="value" id="rel_mouse_x-trace">0</span>	<span class="label">relMouseY: </span><span class="value" id="rel_mouse_y-trace">0</span>
</div>
</div>
</div>
<h3>Placing the image</h3>
<p>
So now that we know where the mouse is in relation to our "stage" div, we just need to put the "follower" image in that same spot. We could place the image in the same <code>mousemove</code> handler. However, this can lead to jerky performance in some browsers and won't allow us to do the more sophisticated animations that are discussed in later tutorials.
</p>
<p>For a smoother, more robust animation, we're going to create a function that we will run at a fixed time interval. For those Flash developers out there, this is similar to the <code>onEnterFrame</code> event.
</p>
<p>So the first thing we need to do is to setup our fixed interval function. 30 Hz or 30 frames per second is a standard animation rate. It's fast enough that your eye doesn't notice any jitter, but slow enough that older computers can usually handle it. Most monitors operate at 60 Hz, so going faster than that won't change the resulting effects. If you have a really complex computation driving your animation, you may want to reduce the rate to 20 or even 10 Hz to avoid bogging down the user's computer. One of the big complaints of Flash animation is how slow it makes the computer. The last thing you want is for your website to slow a user's computer to a crawl.
</p>
<p>In Javascript to repeatedly call a function at a fixed interval of time we use the <code>setInterval</code> function. As parameters, it takes the function you wish to call at that frequency and the amount of time in milliseconds that you want the function called.
</p>
<p>
The following code calculates the time interval in milliseconds for a 30 Hz frame rate and then tells the browser to run the "animateFollower" function at that rate.
</p>
<pre class="code javascript">
frameRate =  30; // the number of frames per second
timeInterval = Math.round( 1000 / frameRate );
atimer = setInterval( "animateFollower()", timeInterval );
</pre>
<p>
You might notice that we set 'atimer' equal to the return value of the setInterval command. This allows us to stop the animateFollower function from running later if we'd like. We won't use it in this tutorial, but it is a good habit to get into.
</p>
<p>
Backing up a little, you'll recall that I gave the image a unique ID to make it easier for later. Well this is where it makes things easy. In jQuery, to get an HTML object by its ID, all you have to do is type $('#OBJECT_ID'). So for our image, we'll call it using $('#follower').
</p>
<p>
So now we just need to make our animateFollower function and have it position the image where the mouse is. And here's the code to do that. As you can see, there really isn't that much to it.
</p>
<pre class="code javascript">
function animateFollower() {
  $('#follower').css('left', relMouseX);
  $('#follower').css('top', relMouseY);
}
</pre>
<p>
And here is our code in action below.
</p>
<div class="demo">
<div id="mouse_follower_demo" class="stage">
	<img src="http://orangesplotch.com/wp-content/uploads/2010/12/egg_16_side.png" id="follower" alt="The mouse follower." />
</div>
</div>
<h3>The End</h3>
<p>
And that's all there is to it. As you can see, with the help of jQuery, it really is very easy to make an object follow the mouse with Javascript. I've used an image in this tutorial, but you can use whatever HTML element your heart desires.
</p>
<p>
I've created a simple demo of the tutorial for you to download and tweak to your hearts content. Try playing with the frame rates to see how smooth or jerky you can make it move. And start having some mouse following fun on your own sites. This is definitely not a Flash only effect anymore.
</p>
<p>Questions or comments are welcome below. Or feel free to <a href="http://orangesplotch.com/contact">contact me</a> directly. Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://orangesplotch.com/mouse_follower-javascript_tutorial/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>SwfObj Grows Up</title>
		<link>http://orangesplotch.com/swfobj-grows-up/</link>
		<comments>http://orangesplotch.com/swfobj-grows-up/#comments</comments>
		<pubDate>Tue, 23 Nov 2010 05:52:00 +0000</pubDate>
		<dc:creator>mattc</dc:creator>
				<category><![CDATA[SwfObj]]></category>
		<category><![CDATA[embed]]></category>
		<category><![CDATA[swfobject]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[wordpress 3.0]]></category>
		<category><![CDATA[wp plugin]]></category>

		<guid isPermaLink="false">http://orangesplotch.com/?p=337</guid>
		<description><![CDATA[After almost a year since the last version was released, SwfObj version 1.0.1 has just published. It includes a new way to incorporate <code>alt</code> content for better <code>HTML5</code> support on browsers that don't support Flash content. Read about all of the changes in this latest SwfObj release.]]></description>
				<content:encoded><![CDATA[<p>It's been almost a year and <a href="http://wordpress.org/extend/plugins/swfobj/">the WordPress SwfObj plugin</a> definitely needs some updating. A lot has happened in the last year with WordPress. To keep SwfObj relevant I've made a few changes with the new release. And I'm finally bumping it up to a 1.0 version. Not sure why I held off on that for so long, perhaps a paranoia that once I tacked on the 1.0 everything would break.</p>
<h2>Keeping up with WordPress 3.0</h2>
<p>There are a couple WordPress developments which are relevant to the SwfObj plugin.</p>
<p>First of all, with the 3.0 release WordPress now uses the latest <code>swfobject.js</code> file (<em>version 2.2</em>) so SwfObj no longer needs to re-register it. As a result, I've linked it up to the default <code>swfobject.js</code> file in WordPress 3.0+ installs. However, <code>swfobject.js</code> is still included in the plugin for WordPress installations that are using version 2.9 or older. The plugin automatically loads the most appropriate file for you.</p>
<p>Speaking of WordPress 2.9, apparently they fixed a bug that prevented me from using wp_enqueue_script in SwfObj and I didn't know about it until recently. Prior to version 2.9, if you set up WordPress on a secure server, with SSL, then the wp_enqueue_script function caused a bunch of security errors to pop up in the browser. Because of this, I avoided using this function. Now that it is fixed, though, I'm using it, which should make the plugin integrate much smoother with any installation of WordPress. Again, I've taken measures to make it backwards compatible with previous versions of WordPress as well.</p>
<h2>A Newer More Powerful Alt</h2>
<p>Additionally I've modified the way <code>alt</code> content is labelled in the shortcode. Several users have had problems getting more complicated <code>alt</code> content to load properly using SwfObj. After trying to escape, unescape, quote and otherwise get the complex <code>alt</code> content they were using to work under the original schema I'd set up, I gave up and decided to rewrite it.</p>
<p>To get the code to render properly, <code>alt</code> content now should be placed between opening and closing swfobj shorttags. Here is an example of the before and after.</p>
<pre><em>Before:</em> &#91;swfobj ... alt="&#60;img src='alt_image.jpg' />"]
<em>After:</em>  &#91;swfobj ...]&#60;img src="alt_image.jpg" />&#91;/swfobj]
</pre>
<p>The change is meant to be simple. The original method is still supported, so upgrading won't break all of the content you've already got embedded in all of your posts. But from here on out I would recommend using the new way to include <code>alt</code> content. It allows you to embed more complicated content to support browsers that don't have Flash. <em>I'm looking at you Apple</em>. The Flash embed button now uses this method to include <code>alt</code> content in the swfobj tags as well.</p>
<h2>Always Squashing Bugs</h2>
<p>I've also fixed several other bugs that users were kind enough to point out to me. I really appreciate all of the feedback everyone has given for this plugin and especially those of you who have been kind enough to donate to the project. Thank you for all of the great support that is helping to make this plugin even better.</p>
<p>If you have any questions, bug reports or suggestions please <a href="/contact">send them over</a>.</p>
<p>Thanks again and happy embedding.</p>
]]></content:encoded>
			<wfw:commentRss>http://orangesplotch.com/swfobj-grows-up/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Bash .. Going Up</title>
		<link>http://orangesplotch.com/bash-going-up/</link>
		<comments>http://orangesplotch.com/bash-going-up/#comments</comments>
		<pubDate>Wed, 17 Nov 2010 08:28:25 +0000</pubDate>
		<dc:creator>mattc</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[bash_aliases]]></category>
		<category><![CDATA[cd]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://orangesplotch.com/?p=317</guid>
		<description><![CDATA[I've been doing a lot of work in the bash shell lately and thought I'd share one of the hacks that makes life just a little easier. Here's a little bash function to make traversing directories easier in the command prompt.]]></description>
				<content:encoded><![CDATA[<p>I've been doing a lot of work in the bash shell lately and thought I'd share one of the hacks that makes life just a little easier. For me, the '<code>cd ..</code>' command is awkward. Especially when trying to go up several directories. <code>cd ../../../..</code> It's easy to get lost on which directory you are on.</p>
<p>I tried looking for a better way online, but couldn't find anything. Because of this, I came up with my own little bash function. And here it is, copied directly from my .bash_aliases file.</p>
<pre class="code shell bash"># Go up directory tree X number of directories
function up() {
	COUNTER="$@";
	# default $COUNTER to 1 if it isn't already set
	if [[ -z $COUNTER ]]; then
		COUNTER=1
	fi
	# make sure $COUNTER is a number
	if [ $COUNTER -eq $COUNTER 2&gt; /dev/null ]; then
		nwd=`pwd` # Set new working directory (nwd) to current directory
		# Loop $nwd up directory tree one at a time
		until [[ $COUNTER -lt 1 ]]; do
			nwd=`dirname $nwd`
			let COUNTER-=1
		done
		cd $nwd # change directories to the new working directory
	else
		# print usage and return error
		echo "usage: up [NUMBER]"
		return 1
	fi
}</pre>
<p>Basically what this function does is allows you to type <code>up X</code> to go up <code>X</code> number of directories. So if I wanted to go up 3 directories, in my bash prompt I would just type <code>up 3</code> instead of <code>cd ../../..</code>.</p>
<p>Additionally, <code>up</code> defaults to going up a single directory. So instead of typing <code>up 1</code> for <code>cd ..</code>, you just have to type <code>up</code>. I've found that I can type <code>up</code> a lot faster than hitting the '.' key twice. For all the time I spend in the bash command prompt, little improvements like this go a long way.</p>
<p>If you think this might help you out, go ahead and copy that function into your <code>.bash_aliases</code> and enjoy.</p>
<h2>An explanation</h2>
<p>For those of you who aren't content to just copy/paste this function into your <code>.bash_aliases</code>, and actually want to know how it works, here's a breakdown of the code above.</p>
<pre class="code shell bash">COUNTER="$@";
# default $COUNTER to 1 if it isn't already set
if [[ -z $COUNTER ]]; then
	COUNTER=1
fi</pre>
<p>This beginning chunk passes any arguments given to <code>$COUNTER</code>. If there is no argument, then <code>$COUNTER</code> is set to <code>1</code>. <code>-z</code> checks if a variable is set to an empty string (i.e. <code>null</code>).</p>
<pre># make sure $COUNTER is a number
if [ $COUNTER -eq $COUNTER 2&gt; /dev/null ]; then</pre>
<p>This is a great trick I learned from <a href="http://grzechu.blogspot.com/2006/06/bash-scripting-checking-if-variable-is.html">http://grzechu.blogspot.com/2006/06/bash-scripting-checking-if-variable-is.html</a> for checking if a variable is numeric or not. It returns <code>1</code> if <code>$COUNTER</code> is a number and <code>0</code> if it isn't. In the <code>else</code> block, at the bottom of the script, I have it print a usage statement telling them to provide a number and then I return a <code>1</code>. Returning a <code>1</code> in a shell script means something went wrong. Returning a <code>0</code> means the script executed without any problems. If the function gets to the end without any return statements it will default to returning a <code>0</code>.</p>
<p>So all of that code is for getting the input, setting it to a default and doing some basic error checking. Now onto the meat of this bash function.</p>
<pre>nwd=`pwd` # Set new working directory (nwd) to current directory</pre>
<p>I think the comment on this line make it pretty clear what we're doing. This is our starting directory and we are going to go up from here.</p>
<pre># Loop $nwd up directory tree one at a time
until [[ $COUNTER -lt 1 ]]; do
	nwd=`dirname $nwd`
	let COUNTER-=1
done</pre>
<p>The until statement is just another form of a <code>while</code> loop in bash. Only it loops while the statement is false instead of while it is true, i.e. "until" the statement becomes true. So here we are looping until our<code> $COUNTER</code> variable is less than <code>1</code>, which would be <code>0</code>.</p>
<p>Each iteration of the loop we set <code>$nwd</code> to the next directory up. We do this by using the <code>dirname</code> command which chops off the last directory in <code>$nwd</code>. The nice thing about <code>dirname</code> is that once you get to the root directory <code>/</code>, it just returns <code>/</code> without throwing any errors. So we don't need to check if <code>$COUNTER</code> is more than the number of directories in our current path. It will just get up to the root directory and stop there.</p>
<p>And of course we need to decrement $COUNTER each iteration.</p>
<pre>cd $nwd # change directories to the new working directory</pre>
<p>Finally we change directories to <code>$nwd</code>. In my original script I changed directories inside the <code>until</code> loop. Instead of setting <code>$nwd</code>, I had a <code>cd ..</code> command. However, doing that meant that I couldn't <code>cd -</code> back to the directory I had started from. Changing the script so that it only does the <code>cd</code> command once meant that <code>cd -</code> still works to get me right back to the original directory. <em>By the way, if you don't know about <code>cd -</code>, it's a very convenient command for jumping back to the directory you were previously in.</em></p>
<p>If you have any questions about this function, or see ways to improve it, please let me know. I may be reinventing the wheel here, but I couldn't find anything online to add this functionality so I thought I'd post my own solution.  If you know of a better way to do this, please post it in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://orangesplotch.com/bash-going-up/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Update on Javascript tutorials</title>
		<link>http://orangesplotch.com/update-on-javascript-tutorials/</link>
		<comments>http://orangesplotch.com/update-on-javascript-tutorials/#comments</comments>
		<pubDate>Wed, 25 Aug 2010 11:45:40 +0000</pubDate>
		<dc:creator>mattc</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[Site]]></category>

		<guid isPermaLink="false">http://orangesplotch.com/blog/?p=305</guid>
		<description><![CDATA[The summer is just about over and I don't have any javascript tutorials to show for it. That isn't to say I haven't been busy working on them, though. In fact, I've been doing a lot of work behind the scenes to upgrade this whole site. As usual it's taking much longer than I intended [...]]]></description>
				<content:encoded><![CDATA[<p>The summer is just about over and I don't have any javascript tutorials to show for it. That isn't to say I haven't been busy working on them, though. In fact, I've been doing a lot of work behind the scenes to upgrade this whole site. As usual it's taking much longer than I intended and is slowing up all of my other endeavors.</p>
<p>Instead of waiting for everything to be pixel-perfect, I'll be updating the blog here shortly with the changes. That way I can start publishing tutorials again. And instead of forcing everything to be perfect before I upgrade the site, I'll probably continue tweaking things indefinitely from here on out.</p>
<p>Look for some changes, and those promised tutorials soon.</p>
<p>[archives]</p>

]]></content:encoded>
			<wfw:commentRss>http://orangesplotch.com/update-on-javascript-tutorials/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash is dead</title>
		<link>http://orangesplotch.com/flash-is-dead/</link>
		<comments>http://orangesplotch.com/flash-is-dead/#comments</comments>
		<pubDate>Thu, 08 Apr 2010 05:51:53 +0000</pubDate>
		<dc:creator>mattc</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://orangesplotch.com/blog/?p=301</guid>
		<description><![CDATA[According to all of the buzz on the interweb these days, Flash is dead. While I doubt that is the case, I do think that there are a lot more things that can now be done without Flash. And I intend to test out that concept throughout the year with some fresh new tutorials.]]></description>
				<content:encoded><![CDATA[<p class="intro">With the release of the iPad this Saturday, Flash is officially dead.</p>
<p>No, I really donâ€™t believe that, but there are plenty of people who do.</p>
<p>To make things a little interesting, this year Iâ€™m going to focus on recreating several of my Actionscript tutorials using Javascript instead. Weâ€™ll see how succesful I am. In any case it should mean that I end up learning a whole lot. Hopefully any readers who come across these tutorials will learn something, too.</p>
]]></content:encoded>
			<wfw:commentRss>http://orangesplotch.com/flash-is-dead/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SwfObj Version 0.9.2</title>
		<link>http://orangesplotch.com/swfobj-version-0-9-2/</link>
		<comments>http://orangesplotch.com/swfobj-version-0-9-2/#comments</comments>
		<pubDate>Sat, 05 Dec 2009 05:17:48 +0000</pubDate>
		<dc:creator>mattc</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[SwfObj]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[embed]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[swfobject]]></category>
		<category><![CDATA[wp plugin]]></category>

		<guid isPermaLink="false">http://orangesplotch.com/blog/?p=252</guid>
		<description><![CDATA[The latest release of SwfObj adds the option to embed your Flash objects dynamically. Now SwfObj fully takes advantage of the SwfObject Javascript library.]]></description>
				<content:encoded><![CDATA[<p class="intro">Big changes are finally here in SwfObj land. Thanks to the encouragement of fantastic SwfObj users, such as yourself, I've mustered up the motivation to implement what I consider to be a major feature. Dynamic Embedding of Flash objects is finally available with SwfObj.</p>
<h3>Dynamic vs. Static Embedding</h3>
<p>Prior to this release, the only option for embedding Flash objects with SwfObj, was statically. This embeds the objects directly into the html rendered by WordPress.</p>
<p>By dynamically embedding them, WordPress instead places a <code>div</code> tag on the page that holds the alternative content only. Once the page has loaded, Javascript replaces this alternative content with the Flash object.</p>
<p>I'll defer you to the official SwfObject project for <a href="http://code.google.com/p/swfobject/wiki/documentation#Should_I_use_the_static_or_dynamic_publishing_method?">the advantages and disadvantages of either SwfObject embedding method</a>.</p>
<h3>How to embed objects dynamically</h3>
<p>By default, SwfObj is set to embed statically. If you would rather use dynamic embedding by default on your site, it is very easy to change the settings. Go to Settings > SwfObj and in "Default Embedding Mode" select "Dynamic Publishing". Save your changes and you're all set.</p>
<p>If you ever want to use the other method for a particular post, you can override the default with the new <code>dynamic_embed</code> attribute. Here are a couple examples.</p>
<pre>&#91;swfobj src="..." dynamic_embed="true"&#93; &larr; <em>(embedded dynamically)</em>
&#91;swfobj src="..." dynamic_embed="false"&#93; &larr; <em>(embedded statically)</em>
</pre>
<h3>Other developments</h3>
<p>In more exciting news, <a href="http://noscope.com/">Joen Asmussen</a> the developer behind the <a href="http://wordpress.org/extend/plugins/flash-shorttags-swfobject/">Flash Shorttags SwfObject Plugin</a> requested that I merge in features from his plugin so he could discontinue it in favor of SwfObj. As a result, you can also use the &#91;flash&#93; shorttag to embed your Flash objects. I really appreciate Joen approaching me about merging our two plugins. It makes things simpler for everyone out there looking for an easier way to embed Flash on their WordPress site.</p>
<p>I originally developed this plugin for myself because embedding Flash was such a pain. It's been great to see so many other people getting value from it as well. Thanks to your help and suggestions SwfObj continues to improve. Please continue to send any comments or suggestions you may have as you use it on your sites. And if you really want to show your appreciation, feel free to <a href="http://orangesplotch.com/freelunch">buy me lunch</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://orangesplotch.com/swfobj-version-0-9-2/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>SwfObj Updates for WP 2.8</title>
		<link>http://orangesplotch.com/swfobj-updates-for-wp-2-8/</link>
		<comments>http://orangesplotch.com/swfobj-updates-for-wp-2-8/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 02:48:19 +0000</pubDate>
		<dc:creator>mattc</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[SwfObj]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[wp 2.8]]></category>

		<guid isPermaLink="false">http://orangesplotch.com/blog/?p=220</guid>
		<description><![CDATA[New release of SwfObj hot off the press. This release uses the newly updated SwfObject 2.2 code as well as fixes an issue for Wordpress users who place their wp-content somewhere other than the default location.]]></description>
				<content:encoded><![CDATA[<p class="intro">
Wordpress just recently released the latest version of their open source blogging platform. Plugin developers everywhere are busy updating their plugins. At least those who procrastinate. SwfObj is no exception. We love jumping on the bandwagon here.
</p>
<p>Actually, I thought SwfObj was ready for the WordPress upgrade. I use a beta version to try and stay ahead of the curve. The plugin worked fine in my beta so it was good. Then I came across <a href="http://plugincheck.bravenewcode.com/">BraveNewCode's plugin checker</a> and discovered the SwfObj plugin was breaking a cardinal rule. <strong>FAIL!</strong></p>
<h3>Plugin No-No</h3>
<p>According to the plugin checker, my plugin was not compatible with the latest WordPress release for the following reason:<br />
<blockquote>Uses 'wp-content' directly in code</p></blockquote>
<p>Translated, this means I was hardcoding the <code>wp-content</code> path in my plugin, rather than using the <code>WP_PLUGIN_URL</code> constant. </p>
<p>As of WordPress 2.6, the <code>wp-content</code> directory can be located anywhere the site admin wants it to be. By hardcoding this path, anyone who had moved it would get errors when they tried to use the SwfObj plugin. There's a good post on how to <a href="http://willnorris.com/2009/05/wordpress-plugin-pet-peeve-hardcoding-wp-content">correct the wp-content hardcoding problem</a> if you are guilty of it too.</p>
<h3>SwfObject 2.2</h3>
<p>SwfObject also released an update. In response, I've updated SwfObj to use the latest SwfObject code, version 2.2. Onward and upward we go!</p>
<p class="aside">And there you have it, the latest SwfObj build. An updated SwfObject release and some compatibility fixes. All are available now at a <a href="http://wordpress.org/extend/plugins/swfobj/">WordPress repository near you</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://orangesplotch.com/swfobj-updates-for-wp-2-8/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Flash Tutorial: Eyes Following the Mouse</title>
		<link>http://orangesplotch.com/flash-tutorial-eyes-following-the-mouse/</link>
		<comments>http://orangesplotch.com/flash-tutorial-eyes-following-the-mouse/#comments</comments>
		<pubDate>Tue, 21 Apr 2009 13:59:25 +0000</pubDate>
		<dc:creator>mattc</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[eye-roll]]></category>
		<category><![CDATA[eyes]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[motion]]></category>

		<guid isPermaLink="false">http://orangesplotch.com/blog/?p=158</guid>
		<description><![CDATA[Have you ever seen those paintings where the eyes are always looking at you no matter where you stand. Well, sorry, this tutorial won't teach you anything about painting. This simple Flash tutorial goes over how to make a pair of eyes follow the mouse using Actionscript.]]></description>
				<content:encoded><![CDATA[<p class="intro">Have you ever seen those paintings where the eyes are always looking at you no matter where you stand. Well, sorry, this tutorial won't teach you anything about painting. This simple Flash tutorial goes over how to make a pair of eyes follow the mouse using Actionscript.</p>
<p><a href="#rollingeyes-source">Jump straight to the source code</a> if you'd like to skip the details.</p>

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="swfobj_0" width="500" height="196" class="align-right bordered">
      <param name="movie" value="http://orangesplotch.com/blog/wp-content/uploads/2009/04/rollingeyes.swf" />
      <param name="wmode" value="transparent" />
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="http://orangesplotch.com/blog/wp-content/uploads/2009/04/rollingeyes.swf" width="500" height="196" wmode="transparent">
      <!--<![endif]-->
        
      <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>

<h3>The eye</h3>
<p>First you need to create three <code>Sprites</code> for each eye. The pupil, the eye, and the mask for the pupil. The mask for the pupil needs to be identical in shape to the part of the eye where the pupil shows. In my case, the eye and the mask for the eye are identical circles. To make things easier on yourself, the registration point for both the pupil and the eye should be located at the center of each.</p>
<p>For this tutorial, I'll be doing everything in basic Actionscript. However, you are free to use images or <code>MovieClip</code>s for your eyes. In fact I'd encourage it, as that will look way better than my goofy circle eyes.</p>
<p class="note">I'm not going to bother pasting my eyeball creation and placement Actionscript here, since it isn't important to the tutorial. If you really want to see it, just <a href="#rollingeyes-source">download the source code</a> at the bottom of the article.</a></p>
<p>So now that you have your eye, pupil and mask, place them on the screen wherever you want. Make sure you mask the pupils with the mask object. Otherwise you'll have some weird floating pupil effect. Again, I'm doing all of this in the Actionscript, but you are free to manually place everything on the stage. That's actually the easier way to do it, since you can see exactly where they are going. </p>
<h3>It follows me everywhere I go</h3>
<p>Ok, enough talk about making and placing eyeballs on the stage. The real reason you are reading this is to see how to get your eyes to follow the mouse. As I said before, the code is really simple. </p>
<p>First calculate the offset between the mouse position and your eye. In this case I have two eyes, so I created the <code>_focalPoint</code> object to compare against. My <code>_focalPoint</code> is located right between the two eyes. This allows both eyes to move together in uniform instead of getting cross-eyed in the middle. The following code goes in your <code>EnterFrame</code> handler function.</p>
<pre>// calculate mouse offset
var distx:Number = mouseX - _focalPoint.x;
var disty:Number = mouseY - _focalPoint.y;</pre>
<p>Finally we reposition the pupils based on this offset. You will notice that we are scaling down <code>distx</code> and <code>disty</code>. This is so the eyes don't move so far that they are no longer visible. I am using a factor of 25. You may need to change this depending on how wide or thin your stage is and where you position the eyes. Experiment a little to get it just right.</p>
<pre>// set the eyes according to the mouse offset
_pupil1.x = _eye1.x + (distx / 25);
_pupil1.y = _eye1.y + (disty / 25);
_pupil2.x = _eye2.x + (distx / 25);
_pupil2.y = _eye2.y + (disty / 25);</pre>
<p>Because we set the registration point of both the eye and the pupil Sprites, we can use the eye <code>.x</code> and <code>.y</code> properties to place the pupil. This makes the code a lot cleaner as you can see.</p>
<p>And there you go. Nice rolling eyes going everywhere your mouse goes. Like I said, it's a very easy effect to make once you know how to do it. No complex trig. No fancy classes. Just plain simple Actionscript.</p>
<h3>Eye Following Downloads</h3>
<ul id="rollingeyes-source" class="downloads">
<li><a title="Download the source file used in this tutorial." type="zip" href="http://orangesplotch.com/files/RollingEyes.zip">Rolling Eyes Actionscript 3.0 source file.</a></li>
</ul>
<p>If you have any questions, please let me know either in the comments below or through the <a href="http://orangesplotch.com/contact/">contact form</a>. I'd love to see what you guys come up with this. So go set your mouse following eyeballs free. Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://orangesplotch.com/flash-tutorial-eyes-following-the-mouse/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
