<?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>Haastek</title>
	<atom:link href="http://haastek.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://haastek.co.uk</link>
	<description>the blog of Luke Haas, focused on design and web-development</description>
	<lastBuildDate>Wed, 20 Oct 2010 11:18:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Introduction to CodeIgniter</title>
		<link>http://haastek.co.uk/2010/10/introduction-to-codeigniter/</link>
		<comments>http://haastek.co.uk/2010/10/introduction-to-codeigniter/#comments</comments>
		<pubDate>Wed, 20 Oct 2010 11:17:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://haastek.co.uk/?p=78</guid>
		<description><![CDATA[
CodeIgniter is a PHP framework, it&#8217;s basically a library of code that you can use to build your own project on top of. Some of the advantages of using CodeIgniter are that it provides you with a really easy way to organize your code in a logical manner. It features a lot of readymade classes [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://haastek.co.uk/2010/10/introduction-to-codeigniter/"><img src="http://haastek.co.uk/wp-content/uploads/2010/10/codeigniter.jpg" alt="Preview" width="580" height="100" /></a><br />
CodeIgniter is a PHP framework, it&#8217;s basically a library of code that you can use to build your own project on top of. Some of the advantages of using CodeIgniter are that it provides you with a really easy way to organize your code in a logical manner. It features a lot of readymade classes to make the laborious tasks, like form validation, simpler and its really well supported, with a great user guide and active community.</p>
<p><span id="more-78"></span></p>
<p>Codeigniter is based on the model-view-controller pattern which divides a system into layers. The view layer is what the user will see and interact with; it&#8217;s typically an HTML page.</p>
<p>The model layer is used to interact with a data source, typically a database. It handles all the SQL queries.</p>
<p>The controller layer goes in between these layers and receives input, performs actions on data, and interacts with the model and view layers.</p>
<p>In this tutorial, I&#8217;m going to explain how to get started with CodeIgniter, what set-up and configuration you have to do, and demonstrate how you would go about building a simple application.</p>
<h2>Step 1: Getting started</h2>
<p>The first thing you&#8217;ll need to do is download <a href="http://codeigniter.com/">CodeIgniter</a>. After that, you can start by creating a controller which will need to be placed in the controller directory. The code for a basic controller looks like this:</p>
<pre class="brush: php">
&lt;?php
class Main extends Controller {

}
?&gt;
</pre>
<p>In this case I&#8217;ve called it Main, this means the file would need to be saved as main.php as the class name should be the same as the filename only with the first letter capitalized.</p>
<p>Similarly, you can create a model in the same way. Just extend model and save it in the model directory.</p>
<pre class="brush: php">
&lt;?php
class Main_model extends Model {

}
?&gt;
</pre>
<h2>Step 2: Configuration</h2>
<p>There is a small amount of configuration to be done, starting with the database. You&#8217;ll need to set your default database, along with the connection details, in the database file in the config directory. Once you&#8217;ve done this, it&#8217;s also a good idea to set a default controller. This can be set in the routes file, also in the config directory. In this case you would set the default controller to main.</p>
<h2>Step 3: The Model</h2>
<p>The model layer is responsible for the interactions with the database. An example method in a model class could be:
<pre class="brush: php">
function select_id($params) {
	$query = $this-&gt;db-&gt;query(&quot;SELECT name, email FROM example WHERE ID = &#039;&quot; . $params[&#039;id&#039;] . &quot;&#039;&quot;);
	return $query-&gt;result_array();
}
</pre>
<h2>Step 4: The Controller</h2>
<p>Functions in a controller are accessed when the method name is defined in the URL structure. For example, the URL http://example.com/index.php/controller/method if the method is named index then this will be called by default. It is also possible to set a constructor method which will be called whenever that controller is accessed, as well as a standard method.</p>
<p>Model classes need to be loaded by a controller before that controller can access that model class&#8217;s methods. This is often done in the constructor.
<pre class="brush: php">
function Main() {
	parent::Controller(); //this line is essential for a constructor
	$this-&gt;load-&gt;model(&#039;main_model&#039;, &#039;&#039;, TRUE); //the TRUE value means the DB is connected to
}
</pre>
<p>After this you could set an index method that calls the method in the model class and then loads a view and passes the results to the view.</p>
<pre class="brush: php">
function index() {
	$params[&#039;id&#039;] = 5;
	$results[&#039;selection&#039;] = $this-&gt;main_model-&gt;select_id($params);
	$this-&gt;load-&gt;view(&#039;view&#039;,$results);

}
</pre>
<h2>Step 5: The View</h2>
<p>The view will mostly be your HTML structure but saved as a .php in the views directory. Views can be split into headers and footers etc, just load them from the controller in the appropriate order.
<p>In this example, the view has been loaded with a result array which can be accessed and displayed using short hand PHP. For example:</p>
<pre class="brush: php">
&lt;ul&gt;
&lt;?php foreach($selection as $result):?&gt;
&lt;li&gt;&lt;?=$result[&#039;name&#039;]?&gt;&lt;/li&gt;
&lt;li&gt;&lt;?=$result[&#039;email&#039;]?&gt;&lt;/li&gt;
&lt;?php endforeach;?&gt;
&lt;/ul&gt;
</pre>
<p>This would loop through the results and display them in a list.</p>
<h2>Conclusion</h2>
<p>This has been a very basic introduction to getting started with CodeIgniter. To learn more, I recommend reading the CodeIgniter <a href="http://codeigniter.com/user_guide/">user guide</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://haastek.co.uk/2010/10/introduction-to-codeigniter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create a Tabbed Interface jQuery Plug-in</title>
		<link>http://haastek.co.uk/2010/10/create-a-tabbed-interface-jquery-plug-in/</link>
		<comments>http://haastek.co.uk/2010/10/create-a-tabbed-interface-jquery-plug-in/#comments</comments>
		<pubDate>Tue, 12 Oct 2010 18:38:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://haastek.co.uk/?p=64</guid>
		<description><![CDATA[
In this tutorial I explain how to create a jQuery plug-in for tabbed interfaces. This is intended to demonstrate how to create simple jQuery plug-ins, the advantages of abstracting your code, and also a few of the things you can do with jQuery.

Get SourceSee Demo
Step 1: Setting up
You can start by defining the HTML structure. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://haastek.co.uk/2010/10/create-a-tabbed-interface-jquery-plug-in//"><img src="http://haastek.co.uk/wp-content/uploads/2010/10/tabs.jpg" alt="Preview" width="580" height="151" /></a><br />
In this tutorial I explain how to create a jQuery plug-in for tabbed interfaces. This is intended to demonstrate how to create simple jQuery plug-ins, the advantages of abstracting your code, and also a few of the things you can do with jQuery.</p>
<p><span id="more-64"></span></p>
<p><a href="http://haastek.co.uk/wp-content/uploads/2010/10/tabbed-interface.zip" class="linkgs">Get Source</a><a href="http://haastek.co.uk/gallery/tabbed-interface" class="linkgs">See Demo</a></p>
<h2>Step 1: Setting up</h2>
<p>You can start by defining the HTML structure. It&#8217;s fairly simple and consists of a div wrapper, which will make it easier when we start working with jQuery, an unordered list, which will house the tab links, and then a div for each tab container.
<pre class="brush: html">
&lt;div id=&quot;tabs&quot;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;#tab1&quot; class=&quot;link_tab&quot; id=&quot;selected&quot;&gt;Tab 1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#tab2&quot; class=&quot;link_tab&quot; &gt;Tab 2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#tab3&quot; class=&quot;link_tab&quot; &gt;Tab 3&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#tab4&quot; class=&quot;link_tab&quot; &gt;Tab 4&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#tab5&quot; class=&quot;link_tab&quot; &gt;Tab 4&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div id=&quot;tab1&quot;&gt;
&lt;h1&gt;Tab 1&lt;/h1&gt;
&lt;p&gt;Example content&lt;/p&gt;

&lt;/div&gt;

&lt;div id=&quot;tab2&quot;&gt;
&lt;h1&gt;Tab 2&lt;/h1&gt;
&lt;p&gt;Example content&lt;/p&gt;
&lt;/div&gt;

&lt;div id=&quot;tab3&quot;&gt;
&lt;h1&gt;Tab 3&lt;/h1&gt;
&lt;p&gt;Example content&lt;/p&gt;
&lt;/div&gt;

&lt;div id=&quot;tab4&quot;&gt;
&lt;h1&gt;Tab 4&lt;/h1&gt;
&lt;p&gt;Example content&lt;/p&gt;
&lt;/div&gt;

&lt;div id=&quot;tab5&quot;&gt;
&lt;h1&gt;Tab 5&lt;/h1&gt;
&lt;p&gt;Example content&lt;/p&gt;
&lt;/div&gt;
</pre>
<h2>Step 2: Styling</h2>
<p>As far as aesthetic styling goes, you can do whatever you want. However, there are a couple of important structural rules to apply. As the tab content divs will need to be on top of each other, they will need to be positioned absolutely which means that the div wrapper will need to be relative so that you can position those divs against the wrapper rather than the page.</p>
<p>The styling I have applied is as follows:</p>
<pre class="brush: css">
#tabs {
	position: relative;
	float: left;
	font-family: verdana, sans-serif;
}
#tabs ul {
	list-style: none;
	margin-left: 12px;
	padding: 0;
}
#tabs li {
	float: left;
	margin-right: 4px;
}
.link_tab {
	text-decoration: none;
	width: 105px;
	height: 21px;
	display: block;
	text-align: center;
	color: #047198;
	font-weight: bold;
	background-color: #DFEDF0;
	padding: 3px;

}
.link_tab:hover {
	background-color: #D1E3E7;
}
.link_tab:focus {
	outline: 0 none;
}
#tabs div {
	-moz-box-shadow: 0 -5px 15px #E1E1E1;
	-webkit-box-shadow: 0 -5px 15px #E1E1E1;
	z-index: 1;
	top: 43px;
	left: 0px;
	width: 580px;
	padding: 0 10px 0 10px;

}
#tabs h1 {
	color: #047198;
	font-weight: normal;
}
#selected {
	-moz-box-shadow: 0 -6px 15px #E1E1E1;
	-webkit-box-shadow: 0 -6px 15px #E1E1E1;
	background-color: #fff;
	z-index: 2;
	position: relative;
}
</pre>
<h2>Step 3: Defining a plug-in</h2>
<p>Plug-ins are a good idea as they increase the reusability of code. It makes sense, if there&#8217;s a segment of code you use a lot, to define it as a plug-in and then just drop it in wherever you need it. One of the necessities of this is that the code is nonspecific, with as few ID and class names as possible so that the code can easily be used in other instances.</p>
<p>To define a jQuery plug-in, you&#8217;ll need to wrap it in a function that looks like this:</p>
<pre class="brush: js">
(function($) {

})(jQuery);
</pre>
<p>Within that we&#8217;re going to define the main plug-in function which looks like this:</p>
<pre class="brush: js">
$.fn.tabbed = function() {

};
</pre>
<p>&#8216;tabbed&#8217; being my chosen name for this plug-in.</p>
<h2>Step 4: Functionality</h2>
<p>Within the main function, defined above, we can add the functionality that is going to perform the intended task. In this case, handling the tab clicks and then transitioning across tab content.</p>
<p>The code for this is as follows:</p>
<pre class="brush: js">
//assign &#039;this&#039; to a variable for scope
var elem = this;
$(elem).children(&#039;ul&#039;).children(&#039;li&#039;).children(&#039;a&#039;).click(function() {
	//show which tab is now selected
	$(&#039;.link_tab&#039;).removeAttr(&#039;id&#039;);
	$(this).attr(&#039;id&#039;,&#039;selected&#039;);
    $(elem).children(&#039;div&#039;).fadeOut(400).filter(this.hash).fadeIn(400);
	//return false so the link is not followed
	return false;
});
$(elem).children(&#039;div&#039;).css(&#039;position&#039;,&#039;absolute&#039;).not(&#039;:first&#039;).hide();
</pre>
<p>
This code just assigns a click event to the tab links and then performs a fadout animation on the current tab content, followed by a fadein animation on the tab content to be shown. The tab link that was clicked on is filtered to get the hash value. This is a value that can safely be added to the end of any link as it only has relevance to the client-side. The final line is predominantly for accessibility, if a user has JavaScript disabled then each tabs contents will still be displayed.</p>
<h2>Step 5: Invoking</h2>
<p>This is the final step and it just involves attaching the plug-in to the tab wrapper. In this case, the tab wrapper has an ID of &#8216;tabs&#8217; and the plug-in is called &#8216;tabbed&#8217; so the code looks like this.</p>
<pre class="brush: js">
$(document).ready(function() {
	$(&#039;#tabs&#039;).tabbed();
});
</pre>
<h2>Conclusion</h2>
<p>
I hope this has given you an idea of how to create jQuery plug-ins and the advantages of abstracting code. Or if your interest was simply in creating a tabbed interface then I hope this was sufficiently explanatory. Thanks for reading.</p>
]]></content:encoded>
			<wfw:commentRss>http://haastek.co.uk/2010/10/create-a-tabbed-interface-jquery-plug-in/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Build an Interactive Polaroid Gallery with Actionscript 3 and the Flickr API</title>
		<link>http://haastek.co.uk/2010/02/build-an-interactive-polaroid-gallery-with-actionscript-3-and-the-flickr-api/</link>
		<comments>http://haastek.co.uk/2010/02/build-an-interactive-polaroid-gallery-with-actionscript-3-and-the-flickr-api/#comments</comments>
		<pubDate>Sun, 21 Feb 2010 12:48:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ActionScript]]></category>

		<guid isPermaLink="false">http://haastek.co.uk/?p=51</guid>
		<description><![CDATA[
In this tutorial I explain how to create a Polaroid style Flickr gallery using the Flickr API and then how to apply user actions such as dragging and resizing and to those images.

Get SourceSee Demo
Step 1: Getting Started
To begin with, open Flash and create a new Actionscript 3.0 Flash file.


Set the stage to 800&#215;500 and [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://haastek.co.uk/2010/02/build-an-interactive-polaroid-gallery-with-actionscript-3-and-the-flickr-api/"><img src="http://haastek.co.uk/wp-content/uploads/2010/02/prev2.jpg" alt="preview" width="580" height="155" /></a><br />
In this tutorial I explain how to create a Polaroid style Flickr gallery using the Flickr API and then how to apply user actions such as dragging and resizing and to those images.</p>
<p><span id="more-51"></span></p>
<p><a href="http://haastek.co.uk/wp-content/uploads/2010/02/flickrgallery.zip" class="linkgs">Get Source</a><a href="http://haastek.co.uk/gallery/flickrgallery.html" class="linkgs">See Demo</a></p>
<h2>Step 1: Getting Started</h2>
<p>To begin with, open Flash and create a new Actionscript 3.0 Flash file.
<p>
<img src="http://haastek.co.uk/wp-content/uploads/2010/02/1.jpg" alt="pic1" width="206" height="188" /></p>
<p>Set the stage to 800&#215;500 and then create a new Actionscript file.</p>
<h2>Step 2: The Libraries</h2>
<p>In this tutorial we&#8217;ll be using the as3flickrlib library to interface with the Flickr API. You can download it <a href=”http://code.google.com/p/as3flickrlib/”>here</a> and you&#8217;ll also need the as3corelib library as as3flickrlib is dependent on that. You can download that <a href=”http://code.google.com/p/as3corelib/”>here</a></p>
<h2>Step 3: Setting Up</h2>
<p>Once you&#8217;ve downloaded the libraries, you&#8217;ll need to make them accessible to Flash. To do this, go into preferences and then click on the Actionscript category and then Actionscript 3.0 settings. Here you&#8217;ll be able to add a new source path which you&#8217;ll need to set the location of the libraries you&#8217;ve just downloaded. </p>
<h2>Step 4: Begin Coding</h2>
<p>Start a package and begin by importing the following classes. </p>
<pre class="brush: js">
package
{
  import flash.display.*;
  import flash.events.*;
  import flash.net.URLRequest;
  import flash.filters.DropShadowFilter;
  import flash.geom.Point;
  import flash.system.Security;
  import com.adobe.webapis.flickr.*;
  import com.adobe.webapis.flickr.events.*;
</pre>
<h2>Step 5: The Class</h2>
<p>Start a class that extends Sprite and name it something like FlickrGallery, make sure to give the Actionscript file the same name when you save it. </p>
<pre class="brush: js">
public class FlickrGallery extends Sprite
{
</pre>
<h2>Step 6: The Variables</h2>
<p>Some of these variables can be changed at your discretion such as the minScale and maxScale variables, the maxWidth and maxHeight variables. </p>
<pre class="brush: js">
var xPosition:int = 0; //The X position of an image
	var yPosition:int = 0; //The Y position of an image
	var prevHeight:int; //Store the height of the last image to be loaded
	var imageCounter:int = 0; //Iterate each time an image is added
	var minScale:Number = 0.3; //The minimum scale boundary for images
	var maxScale:Number = 2.5; //The maximum scale boundary for images
	var totalResults:int = 15; //The number of results you want to be pulled from Flickr
	var api_key:String = &quot;&quot;; //your Flickr API key
	var searchQuery:String = &quot;paris&quot;; //the search criteria, change this to what you want
	var user:String = &quot;&quot;; //optional, the NSID of a particular Flickr user
	var photoCollection:PagedPhotoList; //the collected images
	var imageIndex:int = 0; //the image index for the array
	var displayPic:Bitmap = null; //the bitmap that the images will be assigned to
	var dShadow:DropShadowFilter = new DropShadowFilter(); //the shadow that will be applied to the images
	var targetImage:DisplayObject; //the target image for scaling
	var maxWidth:int = 150; //the maximum width that the images will be initialy displayed at
	var maxHeight:int = 200; //the maximum height that the images will be initially displayed at
	var xyPoints:Point; //the x and y points of an image when scaling
	var xyDistance:Number; //the distant between the x and y points and the mouse
	var imagesReturned:int = 0; // the number of images returned
</pre>
<h2>Step 7: Policy Files</h2>
<p>You&#8217;ll need to load Flickr&#8217;s cross domain policy files to enable you to load the images from Flickr in your own domain. </p>
<pre class="brush: js">
	Security.loadPolicyFile(&quot;http://farm1.static.flickr.com/crossdomain.xml&quot;);
   	Security.loadPolicyFile(&quot;http://farm2.static.flickr.com/crossdomain.xml&quot;);
   	Security.loadPolicyFile(&quot;http://farm3.static.flickr.com/crossdomain.xml&quot;);
   	Security.loadPolicyFile(&quot;http://farm4.static.flickr.com/crossdomain.xml&quot;);
	Security.loadPolicyFile(&quot;http://farm5.static.flickr.com/crossdomain.xml&quot;);
</pre>
<h2>Step 8: The Constructor</h2>
<p>Here we&#8217;ll declare the constructor; it will need to be named the same as the class. In this case FlickrGallery. </p>
<pre class="brush: js">
	public function FlickrGallery() {
	  dShadow.distance = 5;
	  dShadow.angle = 90;
	  dShadow.alpha = 0.5;
	  var service:FlickrService = new FlickrService(api_key);
      	  service.addEventListener(FlickrResultEvent.PHOTOS_SEARCH, handleResults);
          service.photos.search(user, searchQuery, &quot;any&quot;, &quot;&quot;, null, null, null, null, -1, &quot;&quot;, totalResults, 1);
    }
</pre>
<p>It starts by setting the distance, angle and alpha of the drop shadow that will be applied to the images. After that a new instance of the FlickrService class is created and then an event listener is attached to the Flickr search which will call the handleResults function when Flickr returns the search results. </p>
<h2>Step 9: Handle the Results</h2>
<p>Following on from the Flickr search in the constructor, the handleResults function starts by using an if statement to check if the search was successful. If it was, then the returned photos are placed in the photoCollection array, the number of images is assigned to the imagesReturned variable and the loadImages function is called. </p>
<pre class="brush: js">
	private function handleResults(event:FlickrResultEvent):void {
		if(event.success) {
			photoCollection = event.data.photos;
			imagesReturned = photoCollection.photos.length;
			loadImages();
	  } else {
		  trace(&quot;Failed to load images.&quot;);
	  }
    }
</pre>
<h2>Step 10: Load the Images</h2>
<p>The loadImages function starts by forming the URL of image to be loaded and then loading it using the URLReequest object and a Loader object. An event listener is then attached to the Loader and is set to call the displayImages function when it completes. </p>
<pre class="brush: js">
	private function loadImages() {
		var picURL:String = &quot;http://static.flickr.com/&quot; + photoCollection.photos[imageIndex].server + &quot;/&quot;
+ photoCollection.photos[imageIndex].id + &quot;_&quot; + photoCollection.photos[imageIndex].secret + &quot;.jpg&quot;;
		imageIndex++;
		var imageRequest:URLRequest = new URLRequest(picURL);
		var loader:Loader = new Loader();
		loader.contentLoaderInfo.addEventListener(Event.COMPLETE,displayImages);
		loader.load(imageRequest);
	}
</pre>
<h2>Step 11: Display the Images</h2>
<p>The displayImages function is large and will be broken up across then next few steps. It starts by assigning the content of the event target, i.e. the loaded image, to the displayPic variable which we declared earlier as a Bitmap. </p>
<pre class="brush: js">
	private function displayImages(event:Event):void {
		displayPic = event.currentTarget.content
		if(displayPic.width&gt;maxWidth) {
			displayPic.height = (displayPic.height/100)*((maxWidth/displayPic.width) * 100);
			displayPic.width = maxWidth;
		}
		if(displayPic.height&gt;maxHeight) {
			displayPic.width = (displayPic.width/100)*((maxHeight/displayPic.height) * 100);
			displayPic.height = maxHeight;
		}
</pre>
<p>After that the width and height of the image is checked against the maxHeight and maxWidth variables to see if the image size is within the required boundaries. If it&#8217;s not, then scaling is performed on the image by assigning the maxWidth or maxHeight to it and then working out the change as a percentage and applying that to the dimension that wasn&#8217;t changed. </p>
<h2>Step 12: Create the Image Holder</h2>
<p>We now need to create the holder for the image which in this case will be a Sprite. First, we create a new Sprite object and apply a colour fill of white to it. Then we draw it as a rectangle with its width and height slightly larger than the image it will be holding. </p>
<pre class="brush: js">
		var holder:Sprite = new Sprite();
		holder.graphics.beginFill(0xFFFFFF);
		holder.graphics.drawRect(0,0,displayPic.width+10,displayPic.height+30);
		holder.graphics.endFill();
		holder.rotation = (Math.round(Math.random() * (1+4-1)) + 1)*-1;
		holder.name = &quot;im&quot; + imageIndex;
		holder.filters = [dShadow];
</pre>
<p>Next, a slight rotation is applied to the holder to give the gallery a kind of rough scattered style a Polaroid gallery needs. Here, its minimum rotation is 1 and its maximum is 4 but you can alter these if you like. The holder is then named according to the imageIndex and then a drop shadow filter is applied to it which we set up in the constructor at the beginning. </p>
<h2>Step 13: Create the Scale Tab</h2>
<p>In this section we create the little tab that goes in the bottom-right corner of the holder, this is what the user drags to resize the image. </p>
<pre class="brush: js">
		var scaler:Sprite = new Sprite();
		scaler.graphics.beginFill(0xBBBBBB);
		scaler.graphics.drawRect(0,0,10,10);
		scaler.graphics.endFill();
		scaler.buttonMode = true;
		scaler.useHandCursor = true;
		scaler.x = displayPic.width - 2;
		scaler.y = displayPic.height + 17;
</pre>
<p>Once again we create a new Sprite object and this time fill it with a light grey colour, but you can use whichever colour you like. We then draw it as a rectangle and set its width and height to 10, we apply buttonMode and useHandCursor so that the cursor turns to a hand when a user hovers over it. We then set its x and y positions based on the width and height of the image associated with it. For the purpose of this tutorial I&#8217;ve kept this part simple and just used a grey square to represent a resize tab but you could use a more meaningful symbol or graphic. </p>
<h2>Step 14: Position the images</h2>
<p>Still working within the displayImages function, we now need to set the position that the current image will appear on the stage at. The first image is positioned at 0,0 or the top left corner of the screen, after that the next image is given the same x coordinate but the y coordinate is calculated based on the previous images height and generated randomly somewhere between 90% and 100% of the previous images height. This further adds to the random scattered style of the gallery. Also, the images are currently organized into columns of 3 but you can alter this if you desire. Just change the number where it says if(imageCounter==3). </p>
<pre class="brush: js">
		if(imageIndex&lt;2) {
			xPosition = 0;
			yPosition = 0;
		} else {
			yPosition = Math.round(Math.random() *
(1+(prevHeight+yPosition)-((prevHeight+yPosition)*0.9)) + ((prevHeight+yPosition)*0.9));
			if(imageCounter==3) {
				xPosition = displayPic.width + xPosition;
				yPosition = 0;
				imageCounter = 0;
			}
		}
		imageCounter++;
		prevHeight = displayPic.height;
		displayPic.x = 5;
		displayPic.y = 5;
		holder.x = xPosition;
		holder.y = yPosition;
</pre>
<p>After the image positions have been calculated we store the image height in the prevHeight variable for use with the next image and then set the x and y coordinates of the image within the holder, in this case 5,5. </p>
<h2>Step 15: Add to Stage</h2>
<p>In this section we add the displayPic and scaler to the holder and add the holder to the stage using the addChild method. Event listeners then need to be added to the holder and scaler, targeting the startImageDrag, stopImageDrag and scaleImage functions. </p>
<pre class="brush: js">
		holder.addChild(displayPic);
		holder.addChild(scaler);
		stage.addChild(holder);
		holder.addEventListener(MouseEvent.MOUSE_DOWN, startImageDrag);
		holder.addEventListener(MouseEvent.MOUSE_UP, stopImageDrag);
		scaler.addEventListener(MouseEvent.MOUSE_DOWN, scaleImage);
		if(imageIndex&lt;imagesReturned) {
			loadImages();
		}
	}
</pre>
<p>And finally ending the displayImages function with a call to the loadImages function to load the next image, if the imageIndex is less than the imagesReturned. </p>
<h2>Step 16: Dragg&#8230;</h2>
<p>The startImageDrag function is called when a mouse down event is detected on the image holder sprite. It brings the target to the forefront of the display list using the setChildIndex method and then invokes the built-in startDrag method on the target. </p>
<pre class="brush: js">
	private function startImageDrag(evt:MouseEvent) {
		stage.setChildIndex(stage.getChildByName(evt.target.name),stage.numChildren-1);
		evt.target.startDrag();
	}
</pre>
<h2>Step 17: And Drop</h2>
<p>The simplest function of all, stopImageDrag is triggered when a mouse up event is detected on the image holder and invokes the stopDrag method on the target. </p>
<pre class="brush: js">
	private function stopImageDrag(evt:MouseEvent) {
		evt.target.stopDrag();
	}
</pre>
<h2>Step 18: Prepare for Scaling</h2>
<p>The scaleImage function is called when a mouse down event is detected on the scaler sprite. It assigns the target parent, i.e. the image holder, to the targetImage variable and then removes the mouse down event listener from it. </p>
<pre class="brush: js">
	private function scaleImage(evt:MouseEvent) {
		targetImage = evt.target.parent;
		targetImage.removeEventListener(MouseEvent.MOUSE_DOWN, startImageDrag);
		stage.addEventListener(MouseEvent.MOUSE_MOVE,startImageScale);
		stage.addEventListener(MouseEvent.MOUSE_UP, stopImageScale);
		xyPoints = new Point(targetImage.x,targetImage.y);
		xyDistance = (Point.distance(new Point(mouseX, mouseY),xyPoints))/targetImage.scaleX;
	}
</pre>
<p>Event listeners are then added to the stage for detecting the starting and stopping of the image resize, these call the startImageScal and stopImageScale functions. After that, the coordinates of the image holder’s position is assigned to the xyPoints point object and the distance between that and the x and y position of the mouse is calculated and assigned to the xyDistance variable. This will be used in the subsequent functions for calculating the resizing of the image. </p>
<h2>Step 19: Scale Image</h2>
<p>The startImageScale is called when the mouse moves, it calculates a new distance between the mouse x and y positions and the x and y position of the image holder. It then scales the image holder, and thus the image, according to the change in distance calculated by dividing the newDistance variable by the initial xyDistance variable. Checks are then made to see if the scaleX or scaleY of the target are greater than the maxScale or less than the MinScale variables and if they are then those variables are assign to the scaleX and scaleY to stop the image from being expanded or shrunk past the boundaries. </p>
<pre class="brush: js">
	private function startImageScale(evt:MouseEvent) {
		var newDistance = Point.distance(new Point(mouseX, mouseY), xyPoints);
		targetImage.scaleX = targetImage.scaleY = newDistance/xyDistance;
		if(targetImage.scaleX&gt;maxScale) {
			targetImage.scaleX = targetImage.scaleY = maxScale;
		} else if(targetImage.scaleX&lt;minScale) {
			targetImage.scaleX = targetImage.scaleY = minScale;
		}
	}
</pre>
<h2>Step 20: Stop Scaling</h2>
<p>The final function of this project is stopImageScale, it&#8217;s called when a mouse up event is triggered from the stage and starts by removing the event listeners on the stage that relate to scaling. It then adds the mouse down event back to the image holder that has just been resized. </p>
<pre class="brush: js">
	private function stopImageScale(evt:MouseEvent) {
		stage.removeEventListener(MouseEvent.MOUSE_MOVE,startImageScale);
		stage.removeEventListener(MouseEvent.MOUSE_UP,stopImageScale);
		targetImage.addEventListener(MouseEvent.MOUSE_DOWN, startImageDrag);
	}
  }
}
</pre>
<p>The closing brackets for the class and package also need to be added here. </p>
<h2>Conclusion</h2>
<p>You can customize this however much you like; there are many things here that can be changed such as the search query, user NSID or the sizes of the images etc. </p>
<p>I hope you found this tutorial useful and thanks for reading.</p>
]]></content:encoded>
			<wfw:commentRss>http://haastek.co.uk/2010/02/build-an-interactive-polaroid-gallery-with-actionscript-3-and-the-flickr-api/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>7 Sites that Provide an Ambient User Experience</title>
		<link>http://haastek.co.uk/2010/01/7-sites-that-provide-an-ambient-user-experience/</link>
		<comments>http://haastek.co.uk/2010/01/7-sites-that-provide-an-ambient-user-experience/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 19:20:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[User Experience]]></category>

		<guid isPermaLink="false">http://haastek.co.uk/?p=38</guid>
		<description><![CDATA[Ambient user experience relates to the tone and personality of a site. It’s about shaping how users feel and influencing their perception. It’s something additional to a site that is unrelated to how the site functions, and providing it can have a powerful effect on users and their emotional connection with a site.
Here is a [...]]]></description>
			<content:encoded><![CDATA[<p>Ambient user experience relates to the tone and personality of a site. It’s about shaping how users feel and influencing their perception. It’s something additional to a site that is unrelated to how the site functions, and providing it can have a powerful effect on users and their emotional connection with a site.</p>
<p>Here is a list of 7 sites that provide an ambient user experience:</p>
<p><a href="http://www.vimeo.com" class="linktit">Vimeo</a><br />
Vimeo&#8217;s homepage features an informal and friendly welcome message as well as making use of sky and sun imagery in the background. These features give the site a warm, relaxed and friendly feel.</p>
<p><a href="http://www.vimeo.com"><img src="http://haastek.co.uk/wp-content/uploads/2010/01/vimeo2.jpg" alt="vimeo" width="580" height="320" /></a></p>
<p><span id="more-38"></span></p>
<p><a href="http://www.geekstorage.com/" class="linktit">Geek Storage</a><br />
It&#8217;s the cartoon illustrations and geek humour on this site that give it a friendly and appealing tone.
</p>
<p><a href="http://www.geekstorage.com/"><img src="http://haastek.co.uk/wp-content/uploads/2010/01/geekstorage2.jpg" alt="geekstorage" width="580" height="320" /></a></p>
<p><a href="http://www.getcodeslam.com/" class="linktit">CodeSlam</a><br />
CodeSlam with its messages like &#8220;Your email is safe in our galaxy too.&#8221; and playful visuals.
</p>
<p><a href="http://www.getcodeslam.com/"><img src="http://haastek.co.uk/wp-content/uploads/2010/01/codeslam2.jpg" alt="CodeSlam" width="580" height="320" /></a></p>
<p><a href="http://www.storenvy.com/" class="linktit">Storenvy</a><br />
Another example of playful imagery that gives the site a fun element.
</p>
<p><a href="http://www.storenvy.com/"><img src="http://haastek.co.uk/wp-content/uploads/2010/01/storenvy.jpg" alt="storenvy" width="580" height="320" /></a></p>
<p><a href="http://family.innocentdrinks.co.uk/" class="linktit">Innocent Drinks</a><br />
Innocent Drinks, particularly the family element of the site gives it a friendly appeal.
</p>
<p><a href="http://family.innocentdrinks.co.uk/"><img src="http://haastek.co.uk/wp-content/uploads/2010/01/innocent.jpg" alt="innocent" width="580" height="317" /></a></p>
<p><a href="www.flickr.com" class="linktit">Flickr</a><br />
Flickr with its quirky welcome messages.
</p>
<p><a href="www.flickr.com"><img src="http://haastek.co.uk/wp-content/uploads/2010/01/flickr.jpg" alt="flickr" width="580" height="320" /></a></p>
<p><a href="http://www.theshowmn.org/" class="linktit">The Show 09</a><br />
The informal text content and wacky illustrations give this site a welcoming and friendly feel.
</p>
<p><a href="http://www.theshowmn.org/"><img src="http://haastek.co.uk/wp-content/uploads/2010/01/theshow.jpg" alt="show" width="580" height="320" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://haastek.co.uk/2010/01/7-sites-that-provide-an-ambient-user-experience/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Set of Hand Drawn Social Media Icons</title>
		<link>http://haastek.co.uk/2010/01/set-of-hand-drawn-social-media-icons/</link>
		<comments>http://haastek.co.uk/2010/01/set-of-hand-drawn-social-media-icons/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 14:51:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Freebies]]></category>

		<guid isPermaLink="false">http://haastek.co.uk/?p=32</guid>
		<description><![CDATA[Here is a free set of 13 hand drawn social media icons. Including icons for YouTube, LastFM, Redit, Stumble Upon, Twitter, Yahoo, Blogger, Delicious, Design Float, Digg, Facebook, Feed and Flickr.


Download here955kb &#124; 14 x PNG &#124; 1 x JPG
]]></description>
			<content:encoded><![CDATA[<p><a href="http://haastek.co.uk/2010/01/set-of-hand-drawn-social-media-icons/"><img src="http://haastek.co.uk/wp-content/uploads/2010/01/prev.jpg" alt="icons" title="prev" width="580" height="156" /></a><br />Here is a free set of 13 hand drawn social media icons. Including icons for YouTube, LastFM, Redit, Stumble Upon, Twitter, Yahoo, Blogger, Delicious, Design Float, Digg, Facebook, Feed and Flickr.
<p><span id="more-32"></span></p>
<p><img src="http://haastek.co.uk/wp-content/uploads/2010/01/group1.jpg" alt="icon group" title="group" width="580" height="575" /></p>
<p><a href="http://haastek.co.uk/wp-content/uploads/2010/01/Haastek_Social_media.zip">Download here<br />955kb | 14 x PNG | 1 x JPG</a></p>
]]></content:encoded>
			<wfw:commentRss>http://haastek.co.uk/2010/01/set-of-hand-drawn-social-media-icons/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Inspiring Images &#8211; Collection 1</title>
		<link>http://haastek.co.uk/2009/12/inspiring-images-collection-1/</link>
		<comments>http://haastek.co.uk/2009/12/inspiring-images-collection-1/#comments</comments>
		<pubDate>Mon, 28 Dec 2009 12:57:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Inspiration]]></category>

		<guid isPermaLink="false">http://haastek.co.uk/?p=26</guid>
		<description><![CDATA[This is part of a series of posts that showcase examples of inspirational graphic design.

















]]></description>
			<content:encoded><![CDATA[<p>This is part of a series of posts that showcase examples of inspirational graphic design.</p>
<p><a href="http://www.designfriendship.com/uploads/design-pretty-green-2.jpg"><img src="http://www.designfriendship.com/uploads/design-pretty-green-2.jpg" width="429" height="429" alt="Inspire1"/></a></p>
<p><span id="more-26"></span></p>
<p><a href="http://www.juliaguther.de/wp-content/uploads/life_is_uncertain.jpg"><img src="http://www.juliaguther.de/wp-content/uploads/life_is_uncertain.jpg" width="450" height="471" alt="Inspire2"/></a></p>
<p><a href="http://1.bp.blogspot.com/_PRzQzazg504/SuTiuICysqI/AAAAAAAABos/b656e936IvY/HL_nyc.jpg"><img src="http://1.bp.blogspot.com/_PRzQzazg504/SuTiuICysqI/AAAAAAAABos/b656e936IvY/HL_nyc.jpg" width="500" height="382" alt="Inspire3"/></a></p>
<p><a href="http://behance.vo.llnwd.net/profiles/57625/projects/169822/576251232047655.jpg"><img src="http://behance.vo.llnwd.net/profiles/57625/projects/169822/576251232047655.jpg" width="400" height="570" alt="Inspire4"/></a></p>
<p><a href="http://img.ffffound.com/static-data/assets/6/7ec531183be20c0a40172245bd748f3a5dbcfcd8_m.jpg"><img src="http://img.ffffound.com/static-data/assets/6/7ec531183be20c0a40172245bd748f3a5dbcfcd8_m.jpg" width="480" height="333" alt="Inspire5"/></a></p>
<p><a href="http://pikaland.com/images/1875.jpg"><img src="http://pikaland.com/images/1875.jpg" width="440" height="440" alt="Inspire6"/></a></p>
<p><a href="http://farm3.static.flickr.com/2783/4196195083_56bacde5bd.jpg"><img src="http://farm3.static.flickr.com/2783/4196195083_56bacde5bd.jpg" width="428" height="428" alt="Inspire7"/></a></p>
<p><a href="http://noisydecentgraphics.typepad.com/design/images/2007/10/30/ffffound1.jpg"><img src="http://noisydecentgraphics.typepad.com/design/images/2007/10/30/ffffound1.jpg" width="400" height="400" alt="Inspire8"/></a></p>
<p><a href="http://www.pixelcreation.fr/fileadmin/img/sas_image/galerie/graphisme/lesgraphiquants/08_les_graphiquants.jpg"><img src="http://www.pixelcreation.fr/fileadmin/img/sas_image/galerie/graphisme/lesgraphiquants/08_les_graphiquants.jpg" width="350" height="522" alt="Inspire9"/></a></p>
<p><a href="http://farm4.static.flickr.com/3131/2742663181_05aa0e23ec.jpg?v=0"><img src="http://farm4.static.flickr.com/3131/2742663181_05aa0e23ec.jpg?v=0" width="400" height="316" alt="Inspire10"/></a></p>
<p><a href="http://www.robertsamuelhanson.com/media/26358/mon-retail-3.png"><img src="http://www.robertsamuelhanson.com/media/26358/mon-retail-3.png" width="400" height="575" alt="Inspire11"/></a></p>
<p><a href="http://lovelypackage.com/wp-content/uploads/2009/11/jackiesmith1.jpg"><img src="http://lovelypackage.com/wp-content/uploads/2009/11/jackiesmith1.jpg" width="538" height="385" alt="Inspire12"/></a></p>
<p><a href="http://www.twigandthistle.com/blog/wp-content/uploads/2009/09/DIY_ice-cream_parlour_buffet_09.png"><img src="http://www.twigandthistle.com/blog/wp-content/uploads/2009/09/DIY_ice-cream_parlour_buffet_09.png" width="400" height="533" alt="Inspire13"/></a></p>
<p><a href="http://www.unplggd.com/uimages/unplggd/012209_sz_love.jpg"><img src="http://www.unplggd.com/uimages/unplggd/012209_sz_love.jpg" width="540" height="355" alt="Inspire13"/></a></p>
<p><a href="http://lovelypackage.com/wp-content/uploads/2009/11/clearspring2.jpg"><img src="http://lovelypackage.com/wp-content/uploads/2009/11/clearspring2.jpg" width="480" height="502" alt="Inspire14"/></a></p>
<p><a href="http://behance.vo.llnwd.net/profiles/70318/projects/139813/703181224827904.jpg"><img src="http://behance.vo.llnwd.net/profiles/70318/projects/139813/703181224827904.jpg" width="340" height="494" alt=""/></a></p>
]]></content:encoded>
			<wfw:commentRss>http://haastek.co.uk/2009/12/inspiring-images-collection-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introduction to jQuery</title>
		<link>http://haastek.co.uk/2009/12/introduction-to-jquery/</link>
		<comments>http://haastek.co.uk/2009/12/introduction-to-jquery/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 19:00:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://haastek.co.uk/?p=19</guid>
		<description><![CDATA[
jQuery is a javascript framework, first released by John Resig in 2006. Today it is the most popular JavaScript framework in the world. jQuery appeals to a wide variety of JavaScript developers, from those just starting out, to seasoned experts. This is in no small part due to the elegance and simplicity of jQuery, with [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://haastek.co.uk/2009/12/introduction-to-jquery/"><img class="alignnone size-full wp-image-20" title="jquery" src="http://haastek.co.uk/wp-content/uploads/2009/12/jquery.jpg" alt="jquery" width="565" height="96" /></a><br />
jQuery is a javascript framework, first released by John Resig in 2006. Today it is the most popular JavaScript framework in the world. jQuery appeals to a wide variety of JavaScript developers, from those just starting out, to seasoned experts. This is in no small part due to the elegance and simplicity of jQuery, with just a few lines of clear and concise code you can create anything from complex animations to advanced ajax functionality.</p>
<p>In this tutorial I will start from the beginning and give you a brief introduction to some of jQuery&#8217;s core concepts such as element selection, manipulation and events.
<p><span id="more-19"></span></p>
<p>The first thing you&#8217;ll need to do is download the jQuery core library from <a href="http://jquery.com/">jquery.com</a> and add a reference to it in your html page.</p>
<p>Now we can start writing some code. As the majority of stuff you&#8217;re most likely to do with jQuery will involve the DOM in some way, we&#8217;ll need to start with the jQuery ready event. This is an event that gets triggered when the page has loaded and the DOM is ready to be accessed.</p>
<pre class="brush: js">
$(document).ready(function() {

});
</pre>
<p>From within this function we can select and manipulate DOM elements. If, for example, you wanted to select an element by it&#8217;s ID, or select a group of elements by their class name, you can do this by using CSS selectors. This is done like this:</p>
<pre class="brush: js">
$(&quot;#nav&quot;)
//this would select an element with the ID of nav
$(&quot;.title&quot;)
//this would select all elements with the class name title
$(&quot;p&quot;)
//this would select all paragraphs
</pre>
<p>Once you have selected an element, or a group of elements, you have a vast array of options when it comes to dealing with that selection. You could:</p>
<pre class="brush: js">
$(&quot;#nav&quot;).css({&#039;width&#039;:&#039;500px&#039;,&#039;height&#039;:&#039;200px&#039;});
//alter it&#039;s css properties
var cont = $(&quot;#nav&quot;).html();
//assign its contents to a variable
$(&quot;#nav&quot;).html(&quot;insert this text&quot;);
//assign content to it
$(&quot;#nav&quot;).hide();
//perform an animation on it
</pre>
<p>And much more, you can also apply events to the elements you have selected. Here are some examples:</p>
<pre class="brush: js">
$(&quot;.title&quot;).click(function() {
//this triggers on a mouse click
});

$(&quot;input&quot;).focus(function() {
//this triggers when an input field gets focus
});

$(&quot;input&quot;).blur(function() {
//this triggers when an input field loses focus
});

$(&quot;#nav&quot;).mouseenter(function() {
//this triggers when the mouse moves over the element
});

$(&quot;#nav&quot;).mouseleave(function() {
//this triggers when the mouse moves over the element
});
</pre>
<p>Now we can put this all togther and create a basic function that gets triggered when an element with the ID of &#8216;nav&#8217; gets clicked on, which then causes the text colour of all the paragraphs on the page to be set to red and their content to be set to the text &#8216;This is a paragraph&#8217;:</p>
<pre class="brush: js">
$(document).ready(function() {
	$(&quot;#nav&quot;).click(function() {
	$(&quot;p&quot;).css({&#039;color&#039;:&#039;#ff0000&#039;});
	$(&quot;p&quot;).html(&quot;This is a paragraph&quot;);
});
});
</pre>
<p>This has been a basic introduction to jQuery, showing you some of the core concepts and functionality. The amount you can do with jQuery is vast and to get a better idea of this, I suggest you have a read through the documentation on the <a href="http://jquery.com/">jQuery</a> site.  It&#8217;s very thorough and informative with lots of great examples and demonstrations. Other useful jQuery sites include <a href="http://jqueryfordesigners.com/">jQuery for Designers</a> and <a href="http://jquery-howto.blogspot.com/">jQuery Howto</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://haastek.co.uk/2009/12/introduction-to-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

