<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>TutorialSwitch</title>
	
	<link>http://www.tutorialswitch.com</link>
	<description>Photoshop and Web Design Tutorials</description>
	<pubDate>Fri, 12 Dec 2008 17:33:27 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
	<language>en</language>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/TutorialSwitch" /><feedburner:info uri="tutorialswitch" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>TutorialSwitch</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>How To Build Quick and Simple AJAX Forms with JSON Responses</title>
		<link>http://feedproxy.google.com/~r/TutorialSwitch/~3/b-f1V_XS_-4/</link>
		<comments>http://www.tutorialswitch.com/web-development/quick-and-simple-ajax-forms-with-json-responses/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 18:46:45 +0000</pubDate>
		<dc:creator>Jay S</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[Web Development]]></category>

		<category><![CDATA[ajax]]></category>

		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.tutorialswitch.com/?p=166</guid>
		<description><![CDATA[In this tutorial, we will go through the steps to setting up an AJAX form, which will return a JSON response used to display success/error messages. We will be using jQuery and jQuery Form Plugin to make this entire process very quick and painless.

Checkout the DEMO used in this tutorial.
Quick overview of the jQuery Form [...]]]></description>
			<content:encoded><![CDATA[<p>In this tutorial, we will go through the steps to setting up an AJAX form, which will return a JSON response used to display success/error messages. We will be using <a href="http://www.jquery.com/" target="_blank">jQuery</a> and <a href="http://malsup.com/jquery/form/" target="_blank">jQuery Form Plugin</a> to make this entire process <strong>very quick and painless</strong>.<br />
<span id="more-166"></span><br />
<a href="http://www.tutorialswitch.com/demos/post_166/" target="_blank">Checkout the DEMO used in this tutorial</a>.</p>
<p>Quick overview of the jQuery Form Plugin (from their website):</p>
<blockquote><p>The jQuery Form Plugin allows you to easily and unobtrusively upgrade HTML forms to use AJAX. The main methods, ajaxForm and ajaxSubmit, gather information from the form element to determine how to manage the submit process. Both of these methods support numerous options which allows you to have full control over how the data is submitted. Submitting a form with AJAX doesn&#8217;t get any easier than this!</p></blockquote>
<p>Ok, now that you have some background, lets begin the tutorial!</p>
<h3>1. Start by Building a Form</h3>
<p>With the jQuery Form Plugin, you can make very complex forms and the plugin has no problem gathering all the form data and sending it over AJAX. For this tutorial however, lets keep it simple and create a contact form (Name, Email, and Message fields). All the fields  in the form will be required.</p>
<p>Make sure to include the following attributes in your form tag, plus a DIV tag which will be used to display success/error messages.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span> <span style="color: #000066;">method</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post&quot;</span> <span style="color: #000066;">action</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit.php&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;contact-us&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;contact-us-message&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;input-box&quot;</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span>&gt;</span>Name<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;name&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;input-box&quot;</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span>&gt;</span>Email<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;email&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;input-box&quot;</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span>&gt;</span>Message<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">textarea</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;message&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">textarea</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Submit&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">form</span>&gt;</span></pre></div></div>

<p><em><strong>Note:</strong> The id attribute for the first DIV tag is the id attribute of the FORM tag + &#8220;-message&#8221;. In the JavaScript source provided in this tutorial, we have setup this custom convention, which helps to ensure the naming of elements is kept consistent throughout the application.</em></p>
<h3>2. Create External JavaScript File (application.js) and Include into Page</h3>
<p>Make sure to also include the <a href="http://www.jquery.com/" target="_blank">jQuery</a> and <a href="http://malsup.com/jquery/form/" target="_blank">jQuery Form Plugin</a> library files exactly in the order shown below.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
...
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jquery-1.2.6.min.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jquery.form.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;application.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span></pre></div></div>

<h3>3. Add JavaScript Code into application.js</h3>
<p>The first section of code contains our <strong>setupAjaxForm</strong> class&#8230;it&#8217;s a small amount of code, but it accomplishes a lot. First, the class sets up the appropriate options for the jQuery Form Plugin. In addition, once a form is submitted, the class handles the JSON response and displays the results above the form. </p>
<p>Feel free to expand upon this class for your own uses :).</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
</pre></td><td class="code"><pre class="javascript javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> setupAjaxForm<span style="color: #009900;">&#40;</span>form_id<span style="color: #339933;">,</span> form_validations<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> form <span style="color: #339933;">=</span> <span style="color: #3366CC;">'#'</span> <span style="color: #339933;">+</span> form_id;
    <span style="color: #003366; font-weight: bold;">var</span> form_message <span style="color: #339933;">=</span> form <span style="color: #339933;">+</span> <span style="color: #3366CC;">'-message'</span>;
&nbsp;
    <span style="color: #006600; font-style: italic;">// en/disable submit button</span>
    <span style="color: #003366; font-weight: bold;">var</span> disableSubmit <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>val<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        $<span style="color: #009900;">&#40;</span>form <span style="color: #339933;">+</span> <span style="color: #3366CC;">' input[type=submit]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'disabled'</span><span style="color: #339933;">,</span> val<span style="color: #009900;">&#41;</span>;
    <span style="color: #009900;">&#125;</span>;
&nbsp;
    <span style="color: #006600; font-style: italic;">// setup loading message</span>
    $<span style="color: #009900;">&#40;</span>form<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ajaxSend</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        $<span style="color: #009900;">&#40;</span>form_message<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'loading'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Loading...'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;
&nbsp;
    <span style="color: #006600; font-style: italic;">// setup jQuery Plugin 'ajaxForm'</span>
    <span style="color: #003366; font-weight: bold;">var</span> options <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
        dataType<span style="color: #339933;">:</span>  <span style="color: #3366CC;">'json'</span><span style="color: #339933;">,</span>
        beforeSubmit<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #006600; font-style: italic;">// run form validations if they exist</span>
            <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> form_validations <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;function&quot;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span>form_validations<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #006600; font-style: italic;">// this will prevent the form from being subitted</span>
                <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span>;
            <span style="color: #009900;">&#125;</span>
            disableSubmit<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span>;
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        success<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>json<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #006600; font-style: italic;">/**
               * The response from AJAX request will look something like this:
               * {&quot;type&quot; : &quot;success&quot;, &quot;message&quot; : &quot;Thank-You for submitting the form!&quot;}
               * Once the jQuery Form Plugin receives the response, it evaluates the string into a JavaScript object, allowing you to access 
               * object members as demonstrated below.
               */</span>
            $<span style="color: #009900;">&#40;</span>form_message<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
            $<span style="color: #009900;">&#40;</span>form_message<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span>json.<span style="color: #660066;">type</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>json.<span style="color: #660066;">message</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'slow'</span><span style="color: #009900;">&#41;</span>;
            disableSubmit<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>;
            <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>json.<span style="color: #660066;">type</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'success'</span><span style="color: #009900;">&#41;</span>
                $<span style="color: #009900;">&#40;</span>form<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">clearForm</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>;
    $<span style="color: #009900;">&#40;</span>form<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ajaxForm</span><span style="color: #009900;">&#40;</span>options<span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Now we need to instantiate the class to make the form active. The instantiation of the class is wrapped by the jQuery event handler which fires when the document is ready.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>36
37
38
</pre></td><td class="code"><pre class="javascript javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">new</span> setupAjaxForm<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'contact-us'</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</pre></td></tr></table></div>

<p>If you would like to add in JavaScript validations before the form is submitted, using the following code.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>36
37
38
39
40
</pre></td><td class="code"><pre class="javascript javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">new</span> setupAjaxForm<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'contact-us'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// field validations go here, make sure to return true (validates) / false (fails).</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</pre></td></tr></table></div>

<h3>4. Setup back-end PHP script for form processing</h3>
<p>The below PHP script is very generic and basic (not even object-oriented). At minimum, the script shows the basic work flow to process POST data and return a JSON response. I would recommend taking the response variable and moving it to a class to ensure your response hash stays consistent throughout your application.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre></td><td class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// response hash</span>
        <span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="">'type'</span><span style="color: #339933;">=&gt;</span><span style="">''</span><span style="color: #339933;">,</span> <span style="">'message'</span><span style="color: #339933;">=&gt;</span><span style="">''</span><span style="color: #009900;">&#41;</span>;
&nbsp;
        try<span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">// do some sort of data validations, very simple example below</span>
            <span style="color: #000088;">$required_fields</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="">'name'</span><span style="color: #339933;">,</span> <span style="">'email'</span><span style="color: #339933;">,</span> <span style="">'message'</span><span style="color: #009900;">&#41;</span>;
            <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$required_fields</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$field</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$field</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                    throw <span style="color: #000000; font-weight: bold;">new</span> Exception<span style="color: #009900;">&#40;</span><span style="">'Required field &quot;'</span><span style="color: #339933;">.</span><span style="color: #990000;">ucfirst</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$field</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="">'&quot; missing input.'</span><span style="color: #009900;">&#41;</span>;
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #666666; font-style: italic;">// ok, field validations are ok</span>
            <span style="color: #666666; font-style: italic;">// now add to data to DB, Send Email, ect.</span>
&nbsp;
            <span style="color: #666666; font-style: italic;">// let's assume everything is ok, setup successful response</span>
            <span style="color: #000088;">$response</span><span style="color: #009900;">&#91;</span><span style="">'type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="">'success'</span>;
            <span style="color: #000088;">$response</span><span style="color: #009900;">&#91;</span><span style="">'message'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="">'Thank-You for submitting the form!'</span>;
        <span style="color: #009900;">&#125;</span>catch<span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$response</span><span style="color: #009900;">&#91;</span><span style="">'type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="">'error'</span>;
            <span style="color: #000088;">$response</span><span style="color: #009900;">&#91;</span><span style="">'message'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$e</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
        <span style="color: #009900;">&#125;</span>
        <span style="color: #666666; font-style: italic;">// now we are ready to turn this hash into JSON</span>
        <span style="color: #990000;">print</span> json_encode<span style="color: #009900;">&#40;</span><span style="color: #000088;">$response</span><span style="color: #009900;">&#41;</span>;
        <span style="color: #990000;">exit</span>;
    <span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>5. Add CSS styles</h3>
<p>Our JavaScript code requires two CSS classes, &#8220;success&#8221; and &#8220;error&#8221; to be setup for the form results. At this point, you should have a functioning form, but it&#8217;s ugly! Spend some time adding some visual styles to match your project and your done! If your stuck, download the files provided at the bottom of this tutorial for some additional guidance.</p>
<p>Hope you enjoyed and found this tutorial useful. As always, if you have any questions, comments, or feedback on improving this site, feel free to leave a comment below.</p>
<img src="http://feeds.feedburner.com/~r/TutorialSwitch/~4/b-f1V_XS_-4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.tutorialswitch.com/web-development/quick-and-simple-ajax-forms-with-json-responses/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.tutorialswitch.com/web-development/quick-and-simple-ajax-forms-with-json-responses/</feedburner:origLink></item>
		<item>
		<title>5 Tutorials on How To Make Yourself Look Like a Zombie</title>
		<link>http://feedproxy.google.com/~r/TutorialSwitch/~3/hjrNOybvRH0/</link>
		<comments>http://www.tutorialswitch.com/photoshop/5-tutorials-on-how-to-make-yourself-look-like-a-zombie/#comments</comments>
		<pubDate>Mon, 08 Dec 2008 16:23:34 +0000</pubDate>
		<dc:creator>Jay S</dc:creator>
		
		<category><![CDATA[Photo Effects]]></category>

		<category><![CDATA[Photoshop]]></category>

		<category><![CDATA[Web Roundups]]></category>

		<category><![CDATA[photoshop yourself into a zombie]]></category>

		<category><![CDATA[photoshop zombie]]></category>

		<category><![CDATA[zombie photoshop tutorial]]></category>

		<guid isPermaLink="false">http://www.tutorialswitch.com/?p=169</guid>
		<description><![CDATA[We are way past Halloween, but one of our users requested a tutorial covering how to turn a picture into a zombie. Since this topic has been covered by several other blogs and sites, I figured it might be nicer to do a roundup instead. Feel free to post links to other similar tutorials in [...]]]></description>
			<content:encoded><![CDATA[<p>We are way past Halloween, but one of our users requested a tutorial covering how to turn a picture into a zombie. Since this topic has been covered by several other blogs and sites, I figured it might be nicer to do a roundup instead.<span id="more-169"></span> Feel free to post links to other similar tutorials in the comments :).</p>
<h3>1. <a href="http://www.shareneedles.com/2006/11/photoshop_zombi.html" target="_blank">Photoshop Zombie Tutorial</a></h3>
<div class="tutorial-image"><img src="http://www.tutorialswitch.com/wp-content/uploads/2008/12/post_169/zombie_tut_1.jpg" alt="" /></div>
<h3>2. <a href="http://www.flash-game-design.com/tutorials/easyZom-photoshop-tutorial.html" target="_blank">Zombie Photoshop Tutorial<br />
</a></h3>
<div class="tutorial-image"><img src="http://www.tutorialswitch.com/wp-content/uploads/2008/12/post_169/zombie_tut_2.jpg" alt="" /></div>
<h3>3. Photoshop make a zombie</h3>
<div class="tutorial-image"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/zkzTHkAMWI4&amp;hl=en&amp;fs=1" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/zkzTHkAMWI4&amp;hl=en&amp;fs=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></div>
<h3>4. Dramatize a Zombie (<a href="http://www.esnips.com/doc/96617c1e-ce8d-4001-8aa9-db08a053e024/Tutorial-Dramatizar-un-zombie" target="_blank">Scribd Version</a>)</h3>
<div class="tutorial-image"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/8TjpriFqGqI&amp;hl=en&amp;fs=1" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/8TjpriFqGqI&amp;hl=en&amp;fs=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></div>
<h3>5. <a href="http://www.dphotojournal.com/photoshop-tutorial-creating-a-zombie/" target="_blank">Halloween Photoshop Tutorial: Creating Zombie</a></h3>
<div class="tutorial-image"><img src="http://www.tutorialswitch.com/wp-content/uploads/2008/12/post_169/zombie_tut_5.jpg" alt="" /></div>
<img src="http://feeds.feedburner.com/~r/TutorialSwitch/~4/hjrNOybvRH0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.tutorialswitch.com/photoshop/5-tutorials-on-how-to-make-yourself-look-like-a-zombie/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.tutorialswitch.com/photoshop/5-tutorials-on-how-to-make-yourself-look-like-a-zombie/</feedburner:origLink></item>
		<item>
		<title>Creating Flaming Text with Photoshop</title>
		<link>http://feedproxy.google.com/~r/TutorialSwitch/~3/tRDrAd6kX68/</link>
		<comments>http://www.tutorialswitch.com/photoshop/creating-flaming-text-with-photoshop/#comments</comments>
		<pubDate>Mon, 27 Oct 2008 19:07:41 +0000</pubDate>
		<dc:creator>Jay S</dc:creator>
		
		<category><![CDATA[Photoshop]]></category>

		<category><![CDATA[Text Effects]]></category>

		<category><![CDATA[fiery text]]></category>

		<category><![CDATA[fire text]]></category>

		<category><![CDATA[flame text]]></category>

		<category><![CDATA[flaming text]]></category>

		<guid isPermaLink="false">http://www.tutorialswitch.com/?p=151</guid>
		<description><![CDATA[In the spirit of Halloween, I decided I would create a tutorial on how to create text engulfed in flames. Sorry no pumpkins, maybe next time :). This tutorial is a bit of a challenge, so if your a beginner, some practice will be required.

Step 1
Create a new document, 600&#215;360 pixels (72 DPI).
Step 2
Set background [...]]]></description>
			<content:encoded><![CDATA[<p>In the spirit of Halloween, I decided I would create a tutorial on how to create text engulfed in flames. Sorry no pumpkins, maybe next time :). This tutorial is a bit of a challenge, so if your a beginner, some practice will be required.</p>
<p><span id="more-151"></span></p>
<h2>Step 1</h2>
<p>Create a new document, <strong>600&#215;360 pixels</strong> (72 DPI).</p>
<h2>Step 2</h2>
<p>Set background layer to black (#000).</p>
<h2>Step 3</h2>
<p>Create text element using the word &#8220;Diablo&#8221;. I used AvQuest font at 94px. Of course you can use whatever font you would like.</p>
<p><img src="http://www.tutorialswitch.com/wp-content/uploads/2008/10/flaming_text_tutorial/firetext_step_3.jpg" alt="Step 3" width="632" height="406" /></p>
<h2>Step 4</h2>
<p>Make a new layer above the &#8220;Diablo&#8221; layer by clicking on the create new layer icon. Set layer name to &#8220;Fire&#8221;. Merge all viewed layers to the &#8220;Fire&#8221; layer with <em>Cmd + Option + Shift + E for Mac or Ctrl + Alt + Shift + E for PC</em>.</p>
<p>Go to <strong>Edit &gt; Transform &gt; Rotate 90 degrees CCW</strong></p>
<h2>Step 5</h2>
<p>With &#8220;Fire&#8221; layer active go to <strong>Filter &gt; Stylize &gt; Wind</strong>. Leave the dialog set to defaults and click OK. Repeat this filtration one or two more times (Use <em>Cmd + F or Ctrl + F</em> to repeat).</p>
<p>Now go to <strong>Edit &gt; Transform &gt; Rotate 90 CW</strong></p>
<p><img src="http://www.tutorialswitch.com/wp-content/uploads/2008/10/flaming_text_tutorial/firetext_step_5.jpg" alt="Step 5" width="600" height="361" /></p>
<h2>Step 6</h2>
<p>The wind filter is a bit to harsh, so we need to blur the effect a bit. With &#8220;Fire&#8221; layer active go to <strong>Filter &gt; Blur &gt; Gaussian Blur</strong>. Set <strong>Radius 1.5 pixels</strong> and click OK.</p>
<p><img src="http://www.tutorialswitch.com/wp-content/uploads/2008/10/flaming_text_tutorial/firetext_step_6a.jpg" alt="Step 6a" width="336" height="332" /></p>
<p>Now for the cool part. Lets add some color :). Go to <strong>Image &gt; Adjust &gt; Hue/Saturation</strong>. Make sure Colorize is checked off, set <strong>Hue to 40</strong>, <strong>Saturation to 100</strong> and click OK.</p>
<p><img src="http://www.tutorialswitch.com/wp-content/uploads/2008/10/flaming_text_tutorial/firetext_step_6b.jpg" alt="Step 6b" width="460" height="524" /></p>
<h2>Step 7</h2>
<p>Duplicate &#8220;Fire&#8221; layer by dragging it to the create new layer icon or with <em>Cmd + J or Ctrl + J</em> to create &#8220;Fire copy&#8221;.</p>
<p>With &#8220;Fire copy&#8221; active g to <strong>Image &gt; Adjust &gt; Hue/Saturation</strong> or <em>Cmd + U or Ctrl + U</em>. Set the <strong>Hue to -40</strong> and click OK.</p>
<p><img src="http://www.tutorialswitch.com/wp-content/uploads/2008/10/flaming_text_tutorial/firetext_step_7a.jpg" alt="Step 7a" width="414" height="222" /></p>
<p>Set mode of &#8220;Fire copy&#8221; layer to the Mode <strong>Color Dodge</strong> and then <strong>merge the layer down onto &#8220;Fire&#8221; layer</strong> by going to <strong>Layer &gt; Merge Down</strong></p>
<p><img src="http://www.tutorialswitch.com/wp-content/uploads/2008/10/flaming_text_tutorial/firetext_step_7b.jpg" alt="Step 7b" width="415" height="194" /></p>
<h2>Step 8</h2>
<p>Now comes the tricky part. We will use Liquify filter to make the flames more realistic. This step will take some practice, so try to be as patient as possible.</p>
<p>With &#8220;Fire&#8221; layer active, use the following keyboard shortcut,<em> Cmd + Shift + X (MAC) or Ctrl + Shift + X</em> (PC), this will bring up the Liquify filter.</p>
<p>The Warp tool is selected by default. In the dialog box set the <strong>Brush          Size to 50 and the Brush Pressure to 40</strong>. Now click-drag the initial flame          shapes up from the edges of the white text areas. Wiggle the mouse as          you drag up. This first run creates the major flame shapes.</p>
<p>For the second run, create smaller flames by reducing the <strong>Brush Size          to 30 and the Brush Pressure to 35</strong>. Now you will need work each flame until you start seeing my results. This will require you to change brush sizes and really get in and work each flame. It will take some time and practice, but you can do it!</p>
<p>If you want to start over you can Reset back to the undistorted version          by holding down Option for Mac or Alt for PC and clicking the Reset button          that appears to replace the Cancel button. You can also use the Reconstruct          tool to remove or rework your distortions. Once your happy with the results, click OK.</p>
<p><img src="http://www.tutorialswitch.com/wp-content/uploads/2008/10/flaming_text_tutorial/firetext_step_8a.jpg" alt="Step 8a" width="326" height="162" /></p>
<h2>Step 9</h2>
<p>Move the original &#8220;Diablo&#8221; text layer to the top of the layers.</p>
<p>Set to color of the text to black (#000)</p>
<p><img src="http://www.tutorialswitch.com/wp-content/uploads/2008/10/flaming_text_tutorial/firetext_step_9a.jpg" alt="Step 9a" width="356" height="208" /></p>
<p>You can choose to stop here if you want the original Diablo logo. Our next objective is to make the text look like it is all on fire and has been burning for a bit.</p>
<p>I want to give the appearance of cracks in the lettering, so we first need to raster the &#8220;Diablo&#8221; text layer. Zoom in a bit, select the Magic Lasso tool, and start making small random cuts into each letter. Examples below show start to finish cracks.</p>
<p><img src="http://www.tutorialswitch.com/wp-content/uploads/2008/10/flaming_text_tutorial/firetext_step_9b.jpg" alt="Step 9b" width="386" height="224" /></p>
<p><img src="http://www.tutorialswitch.com/wp-content/uploads/2008/10/flaming_text_tutorial/firetext_step_9c.jpg" alt="Step 9c" width="314" height="162" /></p>
<p>The black lettering is to dull, so we need to add some more color and texture. First, add a drop shadow to the &#8220;Diablo&#8221; layer. The Blend Mode for the shadow should be set to Multiply and the color to <strong>#b75c0b</strong>.</p>
<p><img src="http://www.tutorialswitch.com/wp-content/uploads/2008/10/flaming_text_tutorial/firetext_step_9d.jpg" alt="Step 9d" width="594" height="454" /></p>
<p>Add an Inner Bevel to the &#8220;Diablo&#8221; layer with a <strong>Highlight color of black (#000)</strong> and <strong>shadow #844600</strong>. Make sure to duplicate the settings below and then tweak from there.</p>
<p><img src="http://www.tutorialswitch.com/wp-content/uploads/2008/10/flaming_text_tutorial/firetext_step_9e.jpg" alt="Step 9e" width="594" height="454" /></p>
<p>Finally, add a <strong>Color Overlay with #f57300</strong>. This will give the illusion of the text blending in with the fire.</p>
<p><img src="http://www.tutorialswitch.com/wp-content/uploads/2008/10/flaming_text_tutorial/firetext_step_9f.jpg" alt="Step 9f" width="594" height="450" /></p>
<p><img src="http://www.tutorialswitch.com/wp-content/uploads/2008/10/flaming_text_tutorial/firetext_step_9g.jpg" alt="Step 9g" width="298" height="144" /></p>
<h2>Step 10</h2>
<p>Duplicate the &#8220;Fire&#8221; layer once again and place the layer &#8220;Fire copy&#8221; at the top of the layers.</p>
<p>Set the mode for &#8220;Fire copy&#8221; to Screen with <em>Option + Shift + S</em>. Then add a layer mask by clicking on the Add Layer Mask icon at the bottom of the Layers palette.</p>
<p>With the linear Gradient tool run a white to black, linear gradient from          the top of the text area to the bottom.</p>
<p>Then use the Smudge tool or Shift to toggle, with a <strong>65 pixel</strong>,          <strong>soft edged brush at 70%</strong>, on the layer mask, dragging up and down to reveal          or hide flames. I also used to the eraser tool on &#8220;Fire copy&#8221; layer because I felt the top of the flames were a bit too bright.</p>
<p><img src="http://www.tutorialswitch.com/wp-content/uploads/2008/10/flaming_text_tutorial/firetext_step_10.jpg" alt="Step 10" width="196" height="106" /></p>
<p>Phewwww, now we&#8217;re done <img src='http://www.tutorialswitch.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> Below is my finished product&#8230;</p>
<p><img src="http://www.tutorialswitch.com/wp-content/uploads/2008/10/flaming_text_tutorial/flaming_text_tutorial.jpg" alt="Step 3" width="600" height="360" /></p>
<p>Hope you enjoyed the tutorial. We look forward to hearing from you about any suggestions or comments about the site. If you have any suggestions for tutorials, please feel free to submit them using the form on the right column.</p>
<img src="http://feeds.feedburner.com/~r/TutorialSwitch/~4/tRDrAd6kX68" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.tutorialswitch.com/photoshop/creating-flaming-text-with-photoshop/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.tutorialswitch.com/photoshop/creating-flaming-text-with-photoshop/</feedburner:origLink></item>
		<item>
		<title>Turn a Digital Photo Into a Polaroid</title>
		<link>http://feedproxy.google.com/~r/TutorialSwitch/~3/Em_raosJY6M/</link>
		<comments>http://www.tutorialswitch.com/photoshop/turn-a-digital-photo-into-a-polaroid/#comments</comments>
		<pubDate>Sun, 19 Oct 2008 21:43:35 +0000</pubDate>
		<dc:creator>Jay S</dc:creator>
		
		<category><![CDATA[Designing]]></category>

		<category><![CDATA[Photoshop]]></category>

		<category><![CDATA[polaroid]]></category>

		<category><![CDATA[polaroid photoshop]]></category>

		<category><![CDATA[polaroid photoshop templates]]></category>

		<guid isPermaLink="false">http://www.tutorialswitch.com/?p=99</guid>
		<description><![CDATA[In this post, I&#8217;m going to show you how to turn a digital photo into an old school Polaroid. There are similar tutorials out there, but most just do a basic white border around a photo. This tutorial provides a bit more realistic version. All the materials (i.e. psd, font, photo, ect.) used in creating [...]]]></description>
			<content:encoded><![CDATA[<p>In this post, I&#8217;m going to show you how to turn a digital photo into an old school Polaroid. There are similar tutorials out there, but most just do a basic white border around a photo. This tutorial provides a bit more realistic version. All the materials (i.e. psd, font, photo, ect.) used in creating this tutorial can be downloaded (.zip) at the end of this post.<span id="more-99"></span></p>
<h2 style="margin-top:30px;">Step 1</h2>
<p>Start off by creating a new document, in my case 640&#215;480 pixels (72 dpi).</p>
<h2>Step 2</h2>
<p>Import your background image and lock the layer. For this image I&#8217;m going to go with a wood background, which I grabbed from <a href="http://www.cgtextures.com" target="_blank">CG Textures</a>.</p>
<p><img class="alignnone size-full wp-image-117" title="step2" src="http://www.tutorialswitch.com/wp-content/uploads/2008/10/step21.jpg" alt="" width="595" height="500" /></p>
<h2>Step 3</h2>
<p>Create a new set (i.e. folder) and under that set create a new layer. On the new layer, make a box (305&#215;340 pixels) with a gray (#EDEDEC) background.</p>
<p><img src="http://www.tutorialswitch.com/wp-content/uploads/2008/10/step3.jpg" alt="" width="678" height="335" /></p>
<h2>Step 4</h2>
<p>Import and crop your picture. My picture is from a recent trip my wife and I made to <a href="http://www.visitbushkillfalls.com/" target="_blank">Bushkill Falls, PA</a> (Really beautiful scenery in the heart of the Poconos).</p>
<p>Make sure to leave about 10-15 pixel border on the left, right, and top of the photo. Leave 60 pixel border on the bottom.</p>
<p><img class="alignnone size-full wp-image-102" title="step4" src="http://www.tutorialswitch.com/wp-content/uploads/2008/10/step4.jpg" alt="" width="406" height="373" /></p>
<h2>Step 5</h2>
<p>Ok, we have the basic elements, so now we need to start making this look more realistic.</p>
<p>First, lets add a shadow around the photo. Right click on the picture layer (on the thumbnail) and choose <strong>Select Layer Transparency</strong>. Now create a new layer, above the picture layer. Make sure that layer is selected and go to <strong>Edit &gt; Stroke</strong>.</p>
<p><img class="alignnone size-full wp-image-103" title="step5" src="http://www.tutorialswitch.com/wp-content/uploads/2008/10/step5.jpg" alt="" width="633" height="315" /></p>
<p>Now go to <strong>Filter &gt; Blur &gt; Gaussian Blur</strong>.</p>
<p><img class="alignnone size-full wp-image-104" title="step5b" src="http://www.tutorialswitch.com/wp-content/uploads/2008/10/step5b.jpg" alt="" width="322" height="325" /></p>
<h2>Step 6</h2>
<p>Select the base layer (border around actual photo) and go to <strong>Filter &gt; Texturizer</strong></p>
<p><img class="alignnone size-medium wp-image-101" title="step6" src="http://www.tutorialswitch.com/wp-content/uploads/2008/10/step6.jpg" alt="" width="264" height="279" /></p>
<p>This will give our base layer a slight bumpy texture, which is pretty close to the actual texture of a Polaroid.</p>
<h2>Step 7</h2>
<p>Add a drop shadow to the base layer.</p>
<p><img class="alignnone size-full wp-image-108" title="step7" src="http://www.tutorialswitch.com/wp-content/uploads/2008/10/step7.jpg" alt="" width="599" height="436" /></p>
<h2>Step 8</h2>
<p>The picture is just too crystal clear&#8230;real Polaroids usually have this yellowish tint to them, plus they are a little grainy.</p>
<p>Select your picture layer and go to <strong>Filter &gt; Noise &gt; Add Noise</strong>.</p>
<p><img class="alignnone size-full wp-image-109" title="step8a" src="http://www.tutorialswitch.com/wp-content/uploads/2008/10/step8a.jpg" alt="" width="319" height="416" /></p>
<p>Then go to <strong>Image &gt; Adjustments &gt; Photo Filter</strong>.</p>
<p><img class="alignnone size-full wp-image-110" title="step8b" src="http://www.tutorialswitch.com/wp-content/uploads/2008/10/step8b.jpg" alt="" width="338" height="284" /></p>
<h2>Step 9</h2>
<p>Add writing to your Polaroid. I&#8217;m going to use &#8220;Gilles&#8217; Comic Font&#8221; with black (#000) color and a font size of 24pt. If you would like to use a different font, I would recommend one that looks like handwriting for the realism.</p>
<p><img class="alignnone size-full wp-image-111" title="step9" src="http://www.tutorialswitch.com/wp-content/uploads/2008/10/step9.jpg" alt="" width="306" height="92" /></p>
<h2>Step 10</h2>
<p>Now for the final final touches. Lets add some minor wear and tear. Create a new layer below the picture layer. We will use two paint brushes, both using the color black (#000).</p>
<p><img class="alignnone size-full wp-image-112" title="step10a" src="http://www.tutorialswitch.com/wp-content/uploads/2008/10/step10a.jpg" alt="" width="296" height="109" /></p>
<p><img class="alignnone size-full wp-image-105" title="step10b" src="http://www.tutorialswitch.com/wp-content/uploads/2008/10/step10b.jpg" alt="" width="311" height="92" /></p>
<p>Use the above two paint brushes or choose your own to add a few minor imperfections to the Polaroid. I also used the blur tool to give the look of a smudge.</p>
<p>After you are done with the brushes, change the opacity on the layer we just created to 50%.</p>
<h2>Step 11</h2>
<p>Rotate the entire set (folder) counter clockwise and now your done!</p>
<p><img class="alignnone size-full wp-image-114" title="Polaroid Photo in Photoshop" src="http://www.tutorialswitch.com/wp-content/uploads/2008/10/creating_a_polaroid_from_a_digitial_photo.jpg" alt="" width="640" height="480" /></p>
<p>Hope you enjoyed this tutorial.  Please feel free comment below and <a href="http://www.tutorialswitch.com/feed/">subscribe to our RSS feed</a> for updates.</p>
<img src="http://feeds.feedburner.com/~r/TutorialSwitch/~4/Em_raosJY6M" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.tutorialswitch.com/photoshop/turn-a-digital-photo-into-a-polaroid/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.tutorialswitch.com/photoshop/turn-a-digital-photo-into-a-polaroid/</feedburner:origLink></item>
		<item>
		<title>YouTube Video in Flash Quick &amp; Easy!</title>
		<link>http://feedproxy.google.com/~r/TutorialSwitch/~3/0vp7UuS5SOk/</link>
		<comments>http://www.tutorialswitch.com/flash/youtube-video-in-flash-quick-easy/#comments</comments>
		<pubDate>Fri, 17 Oct 2008 21:28:18 +0000</pubDate>
		<dc:creator>iksnae</dc:creator>
		
		<category><![CDATA[Flash]]></category>

		<category><![CDATA[video]]></category>

		<category><![CDATA[youtube]]></category>

		<guid isPermaLink="false">http://www.tutorialswitch.com/?p=87</guid>
		<description><![CDATA[In this tutorial I am going to show you how to load YouTube flv stream into your flash application without using the YouTube API.

Create a new AS3 FLA and Actionscript File in same directory. Here are mine.

First we need to setup the doc class for the FLA . Open the FLA and set the Document [...]]]></description>
			<content:encoded><![CDATA[<p>In this tutorial I am going to show you how to load <a href="http://youtube.com" target="_blank">YouTube</a> flv stream into your flash application without using the <a href="http://code.google.com/apis/youtube/overview.html" target="_blank">YouTube API</a>.</p>
<p><span id="more-87"></span></p>
<p>Create a new AS3 FLA and Actionscript File in same directory. Here are mine.<br />
<img src="http://iksnae.com/stash/images/files.jpg" alt="" width="230" height="131" /></p>
<p>First we need to setup the doc class for the FLA . Open the FLA and set the Document Class in the properties panel.</p>
<p><img src="http://iksnae.com/stash/images/props.jpg" alt="" width="651" height="98" /></p>
<p>Then click the pencil icon to open the AS file.</p>
<p>Now we’ll set up the doc class. We need to create a package and declare the class.</p>
<p><img src="http://iksnae.com/stash/images/docclass.jpg" alt="" width="364" height="211" /></p>
<p>Pretty straight forward&#8230;  Go back to the FLA and preview.. You should get the trace.</p>
<p>Create the interface by dragging InputText and Button components on to the stage. I added a Label too, but not necessary.</p>
<p><img src="http://iksnae.com/stash/images/comps.jpg" alt="" width="360" height="119" /></p>
<p>Then create a video component by clicking on the triangular  icon on the top-right of the Library panel.</p>
<p><img src="http://iksnae.com/stash/images/newvideo.png" alt="" width="564" height="108" /></p>
<p>You will be prompted to enter a name and click OK. Use any thing but “video”.  Make sure to select Actionscript-controlled.</p>
<p><img src="http://iksnae.com/stash/images/symbol.png" alt="" width="608" height="135" /></p>
<p>Drag the video component onto the stage. Then arrange and give each component an instance name.</p>
<p>Save the fla.</p>
<p><img src="http://iksnae.com/stash/images/layout.jpg" alt="" width="382" height="325" /></p>
<p>Back to the AS File. This is the biggest one, so take your time.</p>
<p>First, we’ll need to import the packages/classes:</p>
<p><img src="http://iksnae.com/stash/images/imports.jpg" alt="" width="270" height="124" /></p>
<p>Second, we need to declare all our objects in the class.</p>
<p><img src="http://iksnae.com/stash/images/objs.jpg" alt="" width="505" height="185" /></p>
<p>Third, we set up the constructor.</p>
<p>Here we make references to the components on the stage and add listener to catch mouse click.</p>
<p><img src="http://iksnae.com/stash/images/constructor.jpg" alt="" width="404" height="137" /></p>
<p>Fourth, create the internal methods/functions:</p>
<p>- getVideo</p>
<p>- playVideo</p>
<p>- clickHandler</p>
<p>- loaded</p>
<p>- onMetaData</p>
<p><img src="http://iksnae.com/stash/images/methods.jpg" alt="" width="324" height="145" /></p>
<p>okay&#8230; time to flesh out these methods&#8230;</p>
<p>getVideo:</p>
<p>We instantiate the <a href="http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&amp;file=00003207.html" target="_blank">Loader</a> and <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/URLRequest.html" target="_blank">URLRequest</a> objects, passing url to YouTube’s swf player for a specified video. Don’t worry we’re not going to be using it. It just serves as a way to authenticate the session, then we toss it out.</p>
<p><img src="http://iksnae.com/stash/images/getvideo.jpg" alt="" width="452" height="142" /></p>
<p>loaded:</p>
<p>Here&#8217;s where the magic happens. We decode the variables in that YouTube SWF we loaded with the <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/URLVariables.html" target="_blank">URLVariables</a> class and find the token value. Next we create a new url, which is the url for the FLV stream. Store that url and call playVideo()</p>
<p><img src="http://iksnae.com/stash/images/loaded.jpg" alt="" width="519" height="140" /></p>
<p>playVideo:</p>
<p>We init the <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/NetConnection.html" target="_blank">NetConnection</a> object by calling it’s connect method. Then we instantiate the <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/NetStream.html" target="_blank">NetStream</a> object and set client to this.</p>
<p>Next we attach the NetStream to the Video object and call the NetStream’s <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/NetStream.html#play()" target="_blank">play()</a> method, passing new url to video stream.</p>
<p><img src="http://iksnae.com/stash/images/playvideo.jpg" alt="" width="247" height="120" /></p>
<p>At this point our app is ready to go. We just need to wire up the clickHandler to store the video id and call the getVideo method.</p>
<p><img src="http://iksnae.com/stash/images/clickhandler.jpg" alt="" width="330" height="69" /></p>
<p>Your final code should look something like this:</p>
<p><img src="http://iksnae.com/stash/images/finalcode.jpg" alt="" width="599" height="942" /></p>
<p>That’s it! You should have a functioning youtube player. This should be enough to get you started on you own YouTube apps.</p>
<p>Demo:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="325" height="270" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://iksnae.com/stash/richmedia/youtube/YouTube.swf" /><embed type="application/x-shockwave-flash" width="325" height="270" src="http://iksnae.com/stash/richmedia/youtube/YouTube.swf"></embed></object></p>
<img src="http://feeds.feedburner.com/~r/TutorialSwitch/~4/0vp7UuS5SOk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.tutorialswitch.com/flash/youtube-video-in-flash-quick-easy/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.tutorialswitch.com/flash/youtube-video-in-flash-quick-easy/</feedburner:origLink></item>
		<item>
		<title>Create an Intense Eye</title>
		<link>http://feedproxy.google.com/~r/TutorialSwitch/~3/8SqPAA34r5A/</link>
		<comments>http://www.tutorialswitch.com/photoshop/create-an-intense-eye/#comments</comments>
		<pubDate>Mon, 01 Sep 2008 07:09:48 +0000</pubDate>
		<dc:creator>Amaresh</dc:creator>
		
		<category><![CDATA[Photo Effects]]></category>

		<category><![CDATA[Photoshop]]></category>

		<category><![CDATA[blending modes]]></category>

		<category><![CDATA[filters]]></category>

		<category><![CDATA[photo effects]]></category>

		<guid isPermaLink="false">http://www.tutorialswitch.com/?p=65</guid>
		<description><![CDATA[In this Photoshop tutorial we will learn how to add detail and intensity to an image in 5 simple steps.
We&#8217;ll be using simple filters and layer modes and more to add an interesting effect to an otherwise regular stock photo.

Step 1
First of all you need to open up the stock image that we&#8217;ll be using [...]]]></description>
			<content:encoded><![CDATA[<p>In this Photoshop tutorial we will learn how to add detail and intensity to an image in 5 simple steps.<br />
We&#8217;ll be using simple filters and layer modes and more to add an interesting effect to an otherwise regular stock photo.<br />
<span id="more-65"></span></p>
<h2>Step 1</h2>
<p>First of all you need to open up the stock image that we&#8217;ll be using for this tutorial. You can get it <a href="http://turbophoto.com/graphic-design-stock-photos/Images/Eye.JPG">here</a>. Resize the image to 600&#215;450.</p>
<p><img class="alignnone size-full wp-image-66" title="1" src="http://www.tutorialswitch.com/wp-content/uploads/2008/09/1.jpg" alt="" width="500" height="375" /></p>
<h2>Step 2</h2>
<p>Create a new Curves Adjustment layer by clicking on <strong>Layers</strong> &gt; <strong>New Adjustment Layer</strong> &gt; <strong>Curves </strong>and set the curve like the one below :</p>
<p><img class="alignnone size-full wp-image-67" title="2" src="http://www.tutorialswitch.com/wp-content/uploads/2008/09/2.jpg" alt="" width="374" height="430" /></p>
<h2>Step 3</h2>
<p>Now duplicate your original layer, and apply <strong>Filter &gt; Other &gt; High Pass</strong> and set the radius to 4.</p>
<p><img class="alignnone size-full wp-image-68" title="3" src="http://www.tutorialswitch.com/wp-content/uploads/2008/09/3.jpg" alt="" width="304" height="296" /></p>
<h2>Step 4</h2>
<p>Set the Blending Mode of this layer to <strong>Linear</strong><strong> Light</strong>.</p>
<p><img class="alignnone size-full wp-image-70" title="4" src="http://www.tutorialswitch.com/wp-content/uploads/2008/09/4.jpg" alt="" width="500" height="375" /></p>
<h2>Step 5</h2>
<p>Now, to finish it off, apply a Selective Color Adjustment Layer ( <strong>Layer &gt; New Adjustment Layer &gt; Selection Color</strong>) and play around with the settings till you are happy with the outcome.</p>
<p><img class="alignnone size-full wp-image-72" title="5" src="http://www.tutorialswitch.com/wp-content/uploads/2008/09/5.jpg" alt="" width="500" height="375" /></p>
<p>There you go, we&#8217;ve transformed our original picture into a much more intense and detailed one. Please feel free to <a href="http://feeds.feedburner.com/tutorialswitch">subscribe to our RSS feed</a> for updates.</p>
<img src="http://feeds.feedburner.com/~r/TutorialSwitch/~4/8SqPAA34r5A" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.tutorialswitch.com/photoshop/create-an-intense-eye/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.tutorialswitch.com/photoshop/create-an-intense-eye/</feedburner:origLink></item>
		<item>
		<title>Layer Masking in Photoshop</title>
		<link>http://feedproxy.google.com/~r/TutorialSwitch/~3/Eraz1V0EX6k/</link>
		<comments>http://www.tutorialswitch.com/photoshop/layer-masking-in-photoshop/#comments</comments>
		<pubDate>Sun, 31 Aug 2008 08:15:45 +0000</pubDate>
		<dc:creator>Shotormorgh</dc:creator>
		
		<category><![CDATA[Photoshop]]></category>

		<category><![CDATA[Tools &amp; Tips]]></category>

		<category><![CDATA[cut]]></category>

		<category><![CDATA[extract]]></category>

		<category><![CDATA[layer mask]]></category>

		<category><![CDATA[mask]]></category>

		<guid isPermaLink="false">http://www.tutorialswitch.com/?p=17</guid>
		<description><![CDATA[One of the tedious tasks you&#8217;ll often find yourself doing is cutting stuff out, putting them somewhere they don&#8217;t belong and making them fit in. And there are many ways of doing this.
If you&#8217;re not using layer masks by now, then you should really read this.

Say you have an image of fellow you want to [...]]]></description>
			<content:encoded><![CDATA[<p>One of the tedious tasks you&#8217;ll often find yourself doing is cutting stuff out, putting them somewhere they don&#8217;t belong and making them fit in. And there are many ways of doing this.</p>
<p>If you&#8217;re not using layer masks by now, then you should really read this.<br />
<span id="more-17"></span></p>
<p>Say you have an image of fellow you want to cut out of picture A and put it in picture B. There are several ways you could go at it, none of them wrong. You could use the freeform lasso to go around your subject, if you don&#8217;t have a steady hand there&#8217;s the pen tool ofcourse. And if you don&#8217;t happen to have a hand. Well, you could always get some <a href="http://en.wikipedia.org/wiki/Goobacks">Gooback</a> to do it for a buck an hour. (&#8230;) Moving on.</p>
<p>All these methods are sound and there&#8217;s nothing wrong with them. But using a layer mask along side them has it&#8217;s advantages.</p>
<p>When you delete a part of an image to leave a cut-out that part is gone, and the only way to get it back is by undoing or reloading the picture. If you apply a layer mask, nothing is gone. You can come back to make corrections or just disable the mask to get your image back.</p>
<p>How it works is: You apply a layer mask over a layer. This creates, like the function suggests, a mask over your layer. Which you can then paint over and mask parts of your image. The way you do this is by painting black over what you don&#8217;t want to see.</p>
<p>Sounds pretty straightforward, so let&#8217;s give it a try.</p>
<h2>Step 1</h2>
<p>So we start off with an image containing something we want to cut out of. In this case it&#8217;s your friendly neighbourhood Joker. But I don&#8217;t quite like the Gotham City setting. So that&#8217;s what we&#8217;re going to change.</p>
<p><img class="size-medium wp-image-18" title="Joker LayerMask Step 1" src="http://www.tutorialswitch.com/wp-content/uploads/2008/08/step1-300x300.jpg" alt="Mr. Joker" width="300" height="300" /></p>
<h2>Step 2</h2>
<p>The first thing we do is apply the layer mask. You can do this by selecting the layer with the Joker and clicking on the layer mask button on the bottom of the layers panel as shown. When pressed a small white square appears next to the layer.</p>
<p>The chain in the middle of it means that the mask is linked to the layer, they move together just as two normal linked layers. So it is possible by turning off the link to move the layer mask and the layer seperately. Which would be useful if we for instance want to nudge the mask into the right position.</p>
<p><a href="http://www.tutorialswitch.com/wp-content/uploads/2008/08/step-2.jpg"><img class="alignnone size-medium wp-image-21" src="http://www.tutorialswitch.com/wp-content/uploads/2008/08/step-2.jpg" alt="" width="216" height="281" /></a></p>
<h2>Step 3</h2>
<p>I have a picture here of a building in The Hague, this is where we want to place the Joker, don&#8217;t ask me why. So we&#8217;ll create a layer beneath the Joker layer and paste the picture in.</p>
<p><a href="http://www.tutorialswitch.com/wp-content/uploads/2008/08/step-3.jpg"><img class="alignnone size-medium wp-image-22" title="step-3" src="http://www.tutorialswitch.com/wp-content/uploads/2008/08/step-3-300x300.jpg" alt="" width="300" height="300" /></a></p>
<h2>Step 4</h2>
<p>Now comes the fun part, give a click on the white square on the Joker layer. This will select the layer mask, which means that anything you do on the canvas is only applied on the layer mask.</p>
<p>Like I said, there are many ways to cut him out. Choose whatever you find easier. I found it fairly simple with this image to use the magnetic lasso and going around the Joker. Then when I had my selection. I right clicked on the selection &gt; select inverse and then filled the area with black. This left me with the Joker on a different background.</p>
<p>The important thing is that after you make a selection, instead of deleting or cutting out. You make sure that the area around your subject is filled with the colour black. If you do this whilst having selected the layer mask, then you should have something similar to my image.</p>
<p><a href="http://www.tutorialswitch.com/wp-content/uploads/2008/08/step-4.jpg"><img class="alignnone size-medium wp-image-23" title="step-4" src="http://www.tutorialswitch.com/wp-content/uploads/2008/08/step-4-300x300.jpg" alt="" width="300" height="300" /></a></p>
<p>Now you might have jaggy edges, this is no big deal. The beauty of layer masks is that we can fix all this and we can make a million mistakes, erase them and try again.</p>
<p>To get rid of jaggy edges and spots you may have missed you can simply pick a brush, and paint black over the layer mask. Similarly, you can use the eraser to bring back parts of your image.</p>
<p>So, to recap. The layer mask allows you to hide parts of your image without actually making adjustments to the image itself, thus leaving your image intact at all times. Which will not only save you time and headache, but benefit you in the long run as well.</p>
<p>This is just the basic function of layer masks, you can do much more. Try different brushes. Or use it to hide parts of a layer style. Just experiment with it. You&#8217;ll find new uses.</p>
<img src="http://feeds.feedburner.com/~r/TutorialSwitch/~4/Eraz1V0EX6k" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.tutorialswitch.com/photoshop/layer-masking-in-photoshop/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.tutorialswitch.com/photoshop/layer-masking-in-photoshop/</feedburner:origLink></item>
		<item>
		<title>Aqua Gel Text in Photoshop</title>
		<link>http://feedproxy.google.com/~r/TutorialSwitch/~3/OEdSFFDJX-E/</link>
		<comments>http://www.tutorialswitch.com/photoshop/aqua-gel-text-in-photoshop/#comments</comments>
		<pubDate>Sun, 31 Aug 2008 07:04:45 +0000</pubDate>
		<dc:creator>Amaresh</dc:creator>
		
		<category><![CDATA[Photoshop]]></category>

		<category><![CDATA[Text Effects]]></category>

		<category><![CDATA[aqua]]></category>

		<category><![CDATA[gel]]></category>

		<category><![CDATA[text]]></category>

		<guid isPermaLink="false">http://www.tutorialswitch.com/?p=3</guid>
		<description><![CDATA[In this tutorial, we&#8217;ll be using simple layer styles to make a smooth aqua gel effect that you can easily apply to text.

Step 1
Open a new photoshop document,  and apply a radial gradient. I used the colors #250101 and #000000.

Step 2
Now, with a font of your choice, write the desired text. Pick a nice [...]]]></description>
			<content:encoded><![CDATA[<p>In this tutorial, we&#8217;ll be using simple layer styles to make a smooth aqua gel effect that you can easily apply to text.<br />
<span id="more-3"></span></p>
<h2>Step 1</h2>
<p>Open a new photoshop document,  and apply a radial gradient. I used the colors #250101 and #000000.</p>
<p><img title="1" src="http://www.tutorialswitch.com/wp-content/uploads/2008/08/1.jpg" alt="" width="500" height="500" /></p>
<h2>Step 2</h2>
<p>Now, with a font of your choice, write the desired text. Pick a nice bright blue color, I’ve chosen #03c9e1.</p>
<p><img class="alignnone size-full wp-image-5" title="2" src="http://www.tutorialswitch.com/wp-content/uploads/2008/08/2.jpg" alt="" width="500" height="500" /></p>
<h2>Step 3</h2>
<p>Now double click on the text layer and select Bevel and Emboss and use the following settings for it:</p>
<p><img class="alignnone size-full wp-image-6" title="3" src="http://www.tutorialswitch.com/wp-content/uploads/2008/08/3.jpg" alt="" width="426" height="398" /></p>
<p>Here&#8217;s how our text is looking like now :</p>
<p><img class="alignnone size-full wp-image-7" title="3_2" src="http://www.tutorialswitch.com/wp-content/uploads/2008/08/3_2.jpg" alt="" width="500" height="500" /></p>
<h2>Step 4</h2>
<p>Click on Inner Glow and apply the following settings. Choose a dark shade of blue.</p>
<p><img class="alignnone size-full wp-image-8" title="4" src="http://www.tutorialswitch.com/wp-content/uploads/2008/08/4.jpg" alt="" width="424" height="400" /></p>
<p>Our gel effect is almost ready now :</p>
<p><img class="alignnone size-full wp-image-9" title="4_2" src="http://www.tutorialswitch.com/wp-content/uploads/2008/08/4_2.jpg" alt="" width="500" height="500" /></p>
<h2>Step 5</h2>
<p>To make the gel look more realistic, click Inner Shadow and use the settings below:</p>
<p><img class="alignnone size-full wp-image-10" title="5" src="http://www.tutorialswitch.com/wp-content/uploads/2008/08/5.jpg" alt="" width="423" height="401" /></p>
<p>Presto! Our gel text effect is complete!</p>
<p><a href="http://www.tutorialswitch.com/wp-content/uploads/2008/08/gel.jpg"></a><a href="http://www.tutorialswitch.com/wp-content/uploads/2008/08/gel.jpg"><img class="alignnone size-full wp-image-11" title="gel" src="http://www.tutorialswitch.com/wp-content/uploads/2008/08/gel.jpg" alt="" width="500" height="500" /></a></p>
<p>There you go, we&#8217;ve managed to add a gel-type style to your text in 5 simple steps! You can download the PSD from <a href="http://www.tutorialswitch.com/wp-content/uploads/2008/08/gel.rar">here</a>.</p>
<img src="http://feeds.feedburner.com/~r/TutorialSwitch/~4/OEdSFFDJX-E" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.tutorialswitch.com/photoshop/aqua-gel-text-in-photoshop/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.tutorialswitch.com/photoshop/aqua-gel-text-in-photoshop/</feedburner:origLink></item>
	</channel>
</rss>

