<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>developersnippets.com &#187; Programming</title>
	<atom:link href="http://developersnippets.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://developersnippets.com</link>
	<description>developersnippets</description>
	<pubDate>Tue, 02 Dec 2008 17:17:43 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
	<language>en</language>
			<item>
		<title>Ext GWT 1.2 has been released</title>
		<link>http://developersnippets.com/2008/12/02/ext-gwt-12-has-been-released/</link>
		<comments>http://developersnippets.com/2008/12/02/ext-gwt-12-has-been-released/#comments</comments>
		<pubDate>Tue, 02 Dec 2008 16:43:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Ext JS]]></category>

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

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

		<guid isPermaLink="false">http://developersnippets.com/?p=529</guid>
		<description><![CDATA[All Ext GWT users here is a good news, now Ext GWT 1.2 has been released (means the Ext GWT 1.1 has been upgraded with new features and released as 1.2), Yesterday that is on Dec 1, Darell has officially announced the release of Ext GWT 1.2, and explained about the new features in the [...]]]></description>
			<content:encoded><![CDATA[<p>All Ext GWT users here is a good news, now Ext GWT 1.2 has been released (means the Ext GWT 1.1 has been upgraded with new features and released as 1.2), Yesterday that is on Dec 1, Darell has officially announced the release of <a href="http://extjs.com/blog/2008/12/01/ext-gwt-12-released" title="Ext GWT 1.2">Ext GWT 1.2</a>, and explained about the new features in the blog. And he has recommended all the respective users of Ext GWT 1.1 users to upgrade the same to the latest version that is Ext GWT 1.2 now!<span id="more-529"></span></p>
<p><strong>These new features includes:</strong><br />
<strong>Drag and Drop:</strong><br />
In this version of Ext GWT 1.2 it has got a new Drag and Drop (DND) framework. Respective Support is added via the DragSource and DroptTarget classes with specialized subclasses for Grid, Trees, and Lists. The DND code exposes a rich event model to allow precise control of your DND operations.</p>
<p><strong>Form Data Binding:</strong><br />
With the new data binding framework, your model can be &#8220;bound&#8221; to forms and fields. The relationship is bi-directional with updates propagating in both directions. </p>
<p><strong>File Upload</strong><br />
This version introduces a few new fields including the FileUploadField which allows files to be uploaded to the server via standard HTML form submissions.</p>
<p><strong>Examples:</strong></p>
<div id="attachment_530" class="wp-caption alignleft" style="width: 460px"><a href="http://extjs.com/examples"><img src="http://developersnippets.com/wp-content/uploads/2008/12/ext_gwt_1_2.jpg" alt="Ext GWT 1.2" title="ext_gwt_1_2" width="450" height="140" class="size-full wp-image-530" /></a><p class="wp-caption-text">Ext GWT 1.2</p></div>
<p>For Notable new examples are added to the demo applications and which includes <a href="http://extjs.com/examples/dnd/gridtogrid.html" title="Grid to Grid DND">Grid to Grid DND</a>, <a href="http://extjs.com/examples/dnd/reorderingtree.html" title="Reordering Tree">Reordering Tree</a>, <a href="http://extjs.com/examples/dnd/imageorganizer.html" title="Image Organizer">Image Organizer</a>, <a href="http://extjs.com/examples/binding/gridbinding.html" title="Grid Binding">Grid Binding</a>, <a href="http://extjs.com/examples/forms/duallistfield.html" title="DualListField">DualListField</a> and <a href="http://extjs.com/examples" title="More Examples">more examples in action</a></p>
<p><strong>Download:</strong><br />
To download respective Ext GWT 1.2 please visit the Ext GWT <a href="http://extjs.com/products/gxt/download.php" title="download">download page</a>. And for the release notes you can click <a href="http://extjs.com/deploy/gxt-1.2/release_notes.html" title="Release Notes">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://developersnippets.com/2008/12/02/ext-gwt-12-has-been-released/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Finding out Text Differences is Easy with PSPad</title>
		<link>http://developersnippets.com/2008/11/06/finding-out-text-differences-made-easy-with-pspad/</link>
		<comments>http://developersnippets.com/2008/11/06/finding-out-text-differences-made-easy-with-pspad/#comments</comments>
		<pubDate>Thu, 06 Nov 2008 17:15:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[C++]]></category>

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

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

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

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

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

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

		<category><![CDATA[IDE Tool]]></category>

		<guid isPermaLink="false">http://developersnippets.com/?p=428</guid>
		<description><![CDATA[PSPad is a freeware code editor for developer which can be installed in Microsoft Windows Systems. It&#8217;s a freeware editor which is useful for developers to find out Text Differences, not only finding out Text Differences but it has got many features like this is an useful tool for the people who work with plain [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.pspad.com/" title="PSPad">PSPad</a> is a freeware code editor for developer which can be installed in Microsoft Windows Systems. It&#8217;s a freeware editor which is useful for developers to find out Text Differences, not only finding out Text Differences but it has got many features like this is an useful tool for the people who work with plain text, this editor has good formatting functions, which includes a spell checker, we can create web pages very easily and can be used as a good IDE for compilers, <a href="http://www.pspad.com/" title="PSPad">PSPad</a> catches and parses compiler output, integrates external help files, compares versions and many more features.</p>
<p><span id="more-428"></span></p>
<p>This tool is a fully tested tool and was tested in <a href="http://www.pspad.com/links.php?id=16" title="Softpedia labs">Softpedia labs</a>, I would like to recommend this tool because recently I was handling one of the project in which for one of the file I made some changes long back but I could not remember where I made those changes with the old file. So just I opened the respective old file first and through the menu option (Tools -> Text Differences -> Text Diff with This File…) I have opened the new file and compared the respective changes very easily and integrated the code accordingly in the new file, my job is done. I do agree that there might be some tools which does the same job but I would like to recommend it as it is a freeware product both for personal and commercial use and it does not contain any malware.</p>
<div id="attachment_430" class="wp-caption alignleft" style="width: 467px"><a href="http://www.pspad.com/"><img src="http://developersnippets.com/wp-content/uploads/2008/11/pspad_textdifferences.jpg" alt="PSPad Text Differences" title="pspad_textdifferences" width="457" height="135" class="size-full wp-image-430" /></a><p class="wp-caption-text">PSPad Text Differences</p></div>
<p>And one more important feature is it supports most of the file types like C++, Cobol, MS-Dos batch, CSS, Forth, Fortran, FoxPro, HTML, XHTML, INI, Inno Setup, Java, JavaScript, KixStart, Object Pascal, Perl, PHP, Python, RSS, SQL, TCL/TK, Unix ShellScript, VBScript, Visual Basic, X86 assembler and other 120+ languages included as user highlighter definition.</p>
<p>If you would like to know more about this editor, then please do visit the site <a href="http://www.pspad.com/en/" title="PSPad">http://www.pspad.com/en/</a> [English Version]</p>
]]></content:encoded>
			<wfw:commentRss>http://developersnippets.com/2008/11/06/finding-out-text-differences-made-easy-with-pspad/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Code Snippet of handling files in Ruby Programming Language</title>
		<link>http://developersnippets.com/2008/11/01/code-snippet-of-handling-files-in-ruby-programming-language/</link>
		<comments>http://developersnippets.com/2008/11/01/code-snippet-of-handling-files-in-ruby-programming-language/#comments</comments>
		<pubDate>Sat, 01 Nov 2008 17:20:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Programming]]></category>

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

		<category><![CDATA[Programming Tips]]></category>

		<guid isPermaLink="false">http://developersnippets.com/?p=418</guid>
		<description><![CDATA[In the following article we can have a look at the ways of creating new files in Ruby programming language. Also you can learn how to open and read already existing files. Finally you will learn how to rename, delete and also get information on an existing file.
Creating a New File in Ruby Language
You can [...]]]></description>
			<content:encoded><![CDATA[<p>In the following article we can have a look at the ways of creating new files in <a href="http://www.ruby-lang.org/en/" title="Ruby programming language">Ruby programming language</a>. Also you can learn how to <strong>open</strong> and <strong>read</strong> already existing files. Finally you will learn how to <strong>rename</strong>, <strong>delete</strong> and <strong>also get information on an existing file</strong>.<span id="more-418"></span></p>
<p><strong>Creating a New File in Ruby Language</strong><br />
You can create new files in Ruby using the &#8220;new&#8221; method that belongs to &#8220;file&#8221;class. The &#8220;new&#8221; method can handle two arguments, the first argument is the file name of the new file that you want to create. The second argument indicates how you want to open the file, like whether you want to access it only for reading or just writing or both and so on.</p>
<p><strong>Following are some of the file modes used in Ruby:</strong><br />
<strong>r </strong>-  Read only access.<br />
<strong>r+</strong> -  Read and write access.<br />
<strong>w</strong> -  Write only access.<br />
<strong>w+</strong> -  Read and write access<br />
<strong>a</strong> -  Write only access<br />
<strong>a+</strong> -  Read and write access<br />
<strong>b</strong> -  Binary file mode</p>
<p><strong>Example: to create a new file in &#8220;write&#8221; mode:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;temp.txt&quot;</span>, <span style="color:#996600;">&quot;w&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>

<p><strong>To Open Existing Files in Ruby</strong><br />
Existing files can be opened using “open” method belonging to the class &#8220;File&#8221;.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="ruby ruby" style="font-family:monospace;">file = <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;temp.txt&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>

<p>You can open files already created in any of the modes mentioned above.<br />
<strong>Example: to open a file in read-only mode:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="ruby ruby" style="font-family:monospace;">file = <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;temp.txt&quot;</span>, <span style="color:#996600;">&quot;r&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>

<p><strong>You can also check whether a file is already open or not using the method &#8220;closed?&#8221;.</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="ruby ruby" style="font-family:monospace;">file.<span style="color:#9900CC;">closed</span>?</pre></td></tr></table></div>

<p><strong>Output:</strong> Returns True or False, if the file is already open then it returns &#8220;True&#8221; else &#8220;False&#8221;.<br />
<strong>To close a file, you can use &#8220;close&#8221; method belonging to class &#8220;file&#8221;.</strong> </p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="ruby ruby" style="font-family:monospace;">file = <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;temp.txt&quot;</span>, <span style="color:#996600;">&quot;r&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
file.<span style="color:#9900CC;">close</span></pre></td></tr></table></div>

<p><strong>How to rename and delete files in Ruby programming language?</strong><br />
To rename or delete files you can use &#8220;rename&#8221; and &#8220;delete&#8221; methods respectively.<br />
<strong>Example: Creating new file</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;tempfile.txt&quot;</span>, <span style="color:#996600;">&quot;w&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>

<p><strong>Example: Renaming an existing file</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">rename</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;tempfile.txt&quot;</span>, <span style="color:#996600;">&quot;newfile.txt&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>

<p><strong>Example: Deleting an existing file:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">delete</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;newfile.txt&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>

<p><strong>How to get information on Files?</strong><br />
To do more than just creating and opening files you need to use other methods in class &#8220;file&#8221;.<br />
<strong>You can find whether a file exits using &#8220;exists?&#8221; method:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">exists</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;temp.txt&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>

<p><strong>You can check whether a file is really a file or is it some directory, using &#8220;file?&#8221; method:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">file</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;ruby&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>

<p><strong>To check whether it is a directory, use the &#8220;directory?&#8221; method:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">directory</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;ruby&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>

<p><strong>To check whether a file is readable, use &#8220;readable?&#8221; method:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">readable</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;temp.txt&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>

<p><strong>To check whether a file is writable, use &#8220;writable ?&#8221; method:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">writable</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;temp.txt&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>

<p><strong>To check whether a file is executable, use &#8220;executable?&#8221; method:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">executable</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;temp.txt&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>

<p><strong>You can get the file size using the &#8220;size&#8221; method:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">size</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;temp.txt&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>

<p><strong>To check whether file is empty, use &#8220;zero?&#8221; method:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">zero</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;temp.txt&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>

<p><strong>Find out the file type using &#8220;ftype&#8221; method:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">ftype</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;readme.txt&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">ftype</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;../ruby&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">ftype</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;/dev/sda5&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>

<p>The above are only basics of handling files in <a href="http://www.ruby-lang.org/en/" title="Ruby programming language">Ruby programming language</a>. There is more in programing than just handling files. You need a lot of interest and hard work to master these. So, all the best to your journey into Ruby programming!</p>
<p><strong>Articles which you would like to read:</strong><br />
1. <a href="http://developersnippets.com/2008/10/30/remove-duplicates-from-array-using-javascript/" title="Remove duplicates from an array using JavaScript">Remove duplicates from an array using JavaScript</a><br />
2. <a href="http://developersnippets.com/2008/10/29/check-out-the-number-of-occurrences-using-javascript/" title="Check out the number of Occurrences using JavaScript">Check out the number of Occurrences using JavaScript</a><br />
3. <a href="http://developersnippets.com/2008/10/27/adding-a-div-button-to-the-body-tag-dynamically-using-javascript-dom/" title="Adding a div, button to the body tag dynamically using JavaScript DOM">Adding a div, button to the body tag dynamically using JavaScript DOM</a><br />
4. <a href="http://developersnippets.com/2008/10/19/open-e-mail-message-window-onclick-of-a-button-using-javascript/" title="Open e-mail message window onclick of a button using JavaScript">Open e-mail message window onclick of a button using JavaScript</a><br />
5. <a href="http://developersnippets.com/2008/10/19/free-javascript-database-for-your-browser-taffy-db/" title="Free JavaScript database for your browser, Taffy DB">Free JavaScript database for your browser, Taffy DB</a><br />
6. <a href="http://developersnippets.com/2008/09/21/javascript-visitors-browser-detection-code-snippet/" title="JavaScript Visitors Browser Detection Code Snippet">JavaScript Visitors Browser Detection Code Snippet</a><br />
7. <a href="http://developersnippets.com/2008/09/13/netscape-is-the-navigatorappname-for-google-chrome/" title="Netscape is the 'navigator.appName' for Google Chrome">Netscape is the &#8216;navigator.appName&#8217; for Google Chrome</a><br />
8. <a href="http://developersnippets.com/2008/09/01/error-invalid-source-html-for-this-operation/" title="Error: Invalid source HTML for this operation">Error: Invalid source HTML for this operation</a><br />
9. <a href="http://developersnippets.com/2008/08/31/system-error-1072896658-in-ie/" title="System Error: -1072896658 in IE">System Error: -1072896658 in IE</a><br />
10. <a href="http://developersnippets.com/2008/08/16/simple-steps-to-develop-ajax-website-%e2%80%93-developersnippets/" title="Simple steps to develop AJAX Website – DeveloperSnippets">Simple steps to develop AJAX Website – DeveloperSnippets</a></p>
]]></content:encoded>
			<wfw:commentRss>http://developersnippets.com/2008/11/01/code-snippet-of-handling-files-in-ruby-programming-language/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Remove duplicates from an array using JavaScript</title>
		<link>http://developersnippets.com/2008/10/30/remove-duplicates-from-array-using-javascript/</link>
		<comments>http://developersnippets.com/2008/10/30/remove-duplicates-from-array-using-javascript/#comments</comments>
		<pubDate>Thu, 30 Oct 2008 03:03:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[HTML]]></category>

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

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

		<guid isPermaLink="false">http://developersnippets.com/?p=398</guid>
		<description><![CDATA[Here is a simple and easily understandable snippet code, to remove duplicates from an existing array using JavaScript. You guys! might have come across in some situation where in which the array has got some duplicates and want to remove those duplicates to show up unique ones. Below simple JavaScript code does the same, initially [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a simple and easily understandable snippet code, to remove duplicates from an existing array using JavaScript. You guys! might have come across in some situation where in which the array has got some duplicates and want to remove those duplicates to show up unique ones. Below simple JavaScript code does the same, initially the respective array has got some value like below:<span id="more-398"></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> sampleArr<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span><span style="color: #CC0000;">3</span><span style="color: #339933;">,</span><span style="color: #CC0000;">3</span><span style="color: #339933;">,</span><span style="color: #CC0000;">3</span><span style="color: #339933;">,</span><span style="color: #CC0000;">4</span><span style="color: #339933;">,</span><span style="color: #CC0000;">4</span><span style="color: #339933;">,</span><span style="color: #CC0000;">4</span><span style="color: #009900;">&#41;</span>;</pre></td></tr></table></div>

<p>And now your expecting output should be 1,2,3,4 right? yeah it does the same.</p>
<p><strong>JavaScript Code:</strong></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
</pre></td><td class="code"><pre class="javascript javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> sampleArr<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span><span style="color: #CC0000;">3</span><span style="color: #339933;">,</span><span style="color: #CC0000;">3</span><span style="color: #339933;">,</span><span style="color: #CC0000;">3</span><span style="color: #339933;">,</span><span style="color: #CC0000;">4</span><span style="color: #339933;">,</span><span style="color: #CC0000;">4</span><span style="color: #339933;">,</span><span style="color: #CC0000;">4</span><span style="color: #009900;">&#41;</span>; <span style="color: #006600; font-style: italic;">//Declare array</span>
document.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span>uniqueArr<span style="color: #009900;">&#40;</span>sampleArr<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>; <span style="color: #006600; font-style: italic;">//Print the unique value</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//Adds new uniqueArr values to temp array</span>
<span style="color: #003366; font-weight: bold;">function</span> uniqueArr<span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 temp <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
 <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span>0;i<span style="color: #339933;">&lt;</span>a.<span style="color: #660066;">length</span>;i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>contains<span style="color: #009900;">&#40;</span>temp<span style="color: #339933;">,</span> a<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
   temp.<span style="color: #660066;">length</span><span style="color: #339933;">+=</span><span style="color: #CC0000;">1</span>;
   temp<span style="color: #009900;">&#91;</span>temp.<span style="color: #660066;">length</span><span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span>a<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>;
  <span style="color: #009900;">&#125;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #000066; font-weight: bold;">return</span> temp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//Will check for the Uniqueness</span>
<span style="color: #003366; font-weight: bold;">function</span> contains<span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>j<span style="color: #339933;">=</span>0;j<span style="color: #339933;">&lt;</span>a.<span style="color: #660066;">length</span>;j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #339933;">==</span>e<span style="color: #009900;">&#41;</span><span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</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></pre></td></tr></table></div>

<p>You can customize accordingly instead of &#8216;document.write&#8217; you can copy unique values to other array and proceed accordingly.</p>
]]></content:encoded>
			<wfw:commentRss>http://developersnippets.com/2008/10/30/remove-duplicates-from-array-using-javascript/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Check out the number of Occurrences using JavaScript</title>
		<link>http://developersnippets.com/2008/10/29/check-out-the-number-of-occurrences-using-javascript/</link>
		<comments>http://developersnippets.com/2008/10/29/check-out-the-number-of-occurrences-using-javascript/#comments</comments>
		<pubDate>Wed, 29 Oct 2008 16:38:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[HTML]]></category>

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

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

		<guid isPermaLink="false">http://developersnippets.com/?p=395</guid>
		<description><![CDATA[In some scenarios we will have catch hold of number of occurrences while coding, like for example: In a sentence or paragraph I need to find out number of occurrences of a * (Star), how can we handle this using JavaScript, its simple and efficient.
Example: &#8220;DeveloperSnippets was helpful to *Developers, *Designers, *Beginners, and to *Everybody&#8221;

1
2
3
var [...]]]></description>
			<content:encoded><![CDATA[<p>In some scenarios we will have catch hold of number of occurrences while coding, like for example: In a sentence or paragraph I need to find out number of occurrences of a <strong>*</strong> (Star), how can we handle this using JavaScript, its simple and efficient.</p>
<p><strong>Example:</strong> &#8220;DeveloperSnippets was helpful to *Developers, *Designers, *Beginners, and to *Everybody&#8221;<span id="more-395"></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="javascript javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> str <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;DeveloperSnippets was helpful to *Developers, *Designers, *Beginners, and to *Everybody&quot;</span>;
<span style="color: #003366; font-weight: bold;">var</span> occurences <span style="color: #339933;">=</span> str.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/\*/g</span><span style="color: #009900;">&#41;</span>;
document.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span>occurences.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span>;</pre></td></tr></table></div>

<p><strong>Output:</strong> 4</p>
<p><strong>Explanation of the code:</strong><br />
The below line does everything, &#8216;/g&#8217; here is for global, means it will check all occurrences of <strong>*</strong> in a given string globally.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> occurences <span style="color: #339933;">=</span> str.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/\*/g</span><span style="color: #009900;">&#41;</span>;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://developersnippets.com/2008/10/29/check-out-the-number-of-occurrences-using-javascript/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Building Adobe AIR Applications with Flash CS3 - By ADC</title>
		<link>http://developersnippets.com/2008/10/29/building-adobe-air-applications-with-flash-cs3-by-adc/</link>
		<comments>http://developersnippets.com/2008/10/29/building-adobe-air-applications-with-flash-cs3-by-adc/#comments</comments>
		<pubDate>Wed, 29 Oct 2008 03:33:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[AIR]]></category>

		<category><![CDATA[Action Scripting]]></category>

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

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

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

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

		<category><![CDATA[Adobe Air]]></category>

		<category><![CDATA[Flash CS3]]></category>

		<guid isPermaLink="false">http://developersnippets.com/?p=391</guid>
		<description><![CDATA[The great expert from Adobe and the &#8220;Platform Evangelist Lee Brimelow shows you how to start an AIR application in Flash CS3. He also shows how to take an existing Flash project and turn it into an AIR application&#8221;. Guys! this is awesome enough, you can learn how to implement the things with Adobe AIR [...]]]></description>
			<content:encoded><![CDATA[<p>The great expert from Adobe and the &#8220;Platform Evangelist Lee Brimelow shows you how to start an AIR application in Flash CS3. He also shows how to take an existing Flash project and turn it into an AIR application&#8221;. Guys! this is awesome enough, you can learn how to implement the things with Adobe AIR and Flash CS3, not only that we can also learn on converting existing Flash Project to an AIR application.<span id="more-391"></span></p>
<p>Just have a look at it - and learn from Expert</p>
<p><embed src="http://tv.adobe.com/Embed.swf" quality="high" bgcolor="#000000" width="400" height="250" name="AdobeTVPlayer" play="true" loop="false" quality="high" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" flashVars="v=~b64~aHR0cDovL2Fkb2JlLmVkZ2Vib3NzLm5ldC9mbGFzaC9hZG9iZS9hZG9iZXR2Mi9hZGNfcHJlc2VudHMvNjRfYWRjXzAxNC5mbHY/cnNzX2ZlZWRpZD0xNDcyJnhtbHZlcnM9Mg==&#038;w=400&#038;h=250"></embed></p>
]]></content:encoded>
			<wfw:commentRss>http://developersnippets.com/2008/10/29/building-adobe-air-applications-with-flash-cs3-by-adc/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Widgets in the arena of the internet technology</title>
		<link>http://developersnippets.com/2008/10/25/widgets-in-the-arena-of-the-internet-technology/</link>
		<comments>http://developersnippets.com/2008/10/25/widgets-in-the-arena-of-the-internet-technology/#comments</comments>
		<pubDate>Sat, 25 Oct 2008 18:11:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Addons]]></category>

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

		<category><![CDATA[Ext JS]]></category>

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

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

		<category><![CDATA[Technology News]]></category>

		<category><![CDATA[Thoughts to Think about]]></category>

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

		<guid isPermaLink="false">http://developersnippets.com/?p=340</guid>
		<description><![CDATA[Internet technology has undergone a dramatic change since the day of its launch. The kind of growth that the internet has enjoyed in the last decade is incredible. Especially an internet technology like the cloud computing is an awesome one. On-demand services have become the most favorite service of the next generation. While internet technologies [...]]]></description>
			<content:encoded><![CDATA[<p>Internet technology has undergone a dramatic change since the day of its launch. The kind of growth that the internet has enjoyed in the last decade is incredible. Especially an internet technology like the cloud computing is an awesome one. On-demand services have become the most favorite service of the next generation. While internet technologies like the <strong><a href="http://en.wikipedia.org/wiki/Software_as_a_Service" title="Software as a service (SaaS)">Software as a service (SaaS)</a></strong> and <strong><a href="http://en.wikipedia.org/wiki/Platform_as_a_service">Platform as a service (PaaS)</a></strong> gained true momentum, widgets of the internet too have been in vogue enticing and helping both visitors and website owners to achieve their goals. This article will enlighten you on the importance of these wonder working web tools.</p>
<p><span id="more-340"></span></p>
<p>Knowledge on demand has become the ultimate purpose of many websites. Widgets are nothing but mini-applications, which provide effective solutions to visitors&#8217; needs. Widgets of modern times play a crucial role in making the website a magical stage where you get instant answers for your queries. Apart from making a website interesting and interactive one, they provide instant information on news, entertainment, weather, calculations, and many more.</p>
<p>As today&#8217;s web visitors expect more and more from websites, and widgets have become an absolute necessity in order to retain the visitors for a longer period or entice more visitors to your site. If you really want a high traffic to your site, just place a few gadgets that are of great interest to your visitors. Of late, widgets have started attracting web visitors of all ages, and it has been proved that useful and simple widgets increase the traffic of websites in multi-folds. One other specialty of widgets is that users can get easy access to information available on the internet without visiting specific websites. <strong>YouTube videos</strong>, <strong>movie trailers</strong>, <strong>photo slideshows</strong>, <strong>news widgets</strong> are some of the popular widgets for blog sites and websites. Desktop widgets on the other hand can be downloaded and used to access information without having to visit the website. Some of the good examples include the weather gadget offered on websites that forecast weather, new feeds, maps, pictures, videos, and music.</p>
<p>It is a good idea for website promotion too! Do you know that widgets are great marketing tools in the arena of internet marketing? Well, here are a few points on the marketing capability of the widgets. Instead of placing banner ads, website owners can opt for a useful widget that bears the name of the company on it. As it is an interactive tool that provides a service, you are likely to draw more targeted traffic than your banner ads can bring in. Moreover, allowing users to share the widget gets you more inbound links that is a great plus when it comes to search engine optimization for higher page ranking.</p>
<p>Using widgets on you blog could enhance the looks and usability of your blog site. Apart from providing the blog with great looks, it can draw the attention of the visitors to a large extent. For example, blog widgets like <a href="http://www.twitter.com" title="Twitter">Twitter</a> or <a href="http://www.plurk.com" title="Plurk">Plurk</a> on your site will enable your visitors to know what you do, or even help them subscribe to your blog or follow it.</p>
<p>In order to help developers in learning more about the widgets, there are number of dedicated websites that provide useful information on widgets. These websites explain in detail about the widget and its uses. One good example is <a href="http://www.developersnippets.com" title="developersnippets">developersnippets.com</a>. You can find a good number of snippet articles that are from basic to high-level. This site helps young developers wishing to have fruitful career in developing innovative web products.</p>
<p><strong>CloudComputing:</strong><br />
<div id="attachment_342" class="wp-caption alignleft" style="width: 268px"><a href="http://en.wikipedia.org/wiki/Software_as_a_Service"><img src="http://developersnippets.com/wp-content/uploads/2008/10/cloud_computing.jpg" alt="SaaS and Cloud Computing" title="cloud_computing" width="258" height="494" class="size-full wp-image-342" /></a><p class="wp-caption-text">Cloud Computing</p></div></p>
]]></content:encoded>
			<wfw:commentRss>http://developersnippets.com/2008/10/25/widgets-in-the-arena-of-the-internet-technology/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Open e-mail message window onclick of a button using JavaScript</title>
		<link>http://developersnippets.com/2008/10/19/open-e-mail-message-window-onclick-of-a-button-using-javascript/</link>
		<comments>http://developersnippets.com/2008/10/19/open-e-mail-message-window-onclick-of-a-button-using-javascript/#comments</comments>
		<pubDate>Sun, 19 Oct 2008 16:41:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[HTML]]></category>

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

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

		<guid isPermaLink="false">http://developersnippets.com/?p=333</guid>
		<description><![CDATA[This is a simple cross-browser snippet to open an e-mail message window onclick of a button using JavaScript, in some scenarios you might want to open up an e-mail message window when user clicks on a button, yeah this is possible with a simple snippet code which can be included in your onclick event.
Below is [...]]]></description>
			<content:encoded><![CDATA[<p>This is a simple cross-browser snippet to open an e-mail message window onclick of a button using JavaScript, in some scenarios you might want to open up an e-mail message window when user clicks on a button, yeah this is possible with a simple snippet code which can be included in your onclick event.</p>
<p>Below is the respective cross-browser code for the same:<span id="more-333"></span></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
</pre></td><td class="code"><pre class="html4strict html4strict" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span> xmlns<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span>&gt;</span>
<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;">meta</span> <span style="color: #000066;">http-equiv</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Content-Type&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/html; charset=iso-8859-1&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;emailwindow&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;button&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Mail Me at vivek@developersnippets.com&quot;</span> <span style="color: #000066;">onclick</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;self.location='vivek@developersnippets.com'&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;">form</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></td></tr></table></div>

<p>Even the above can be placed in a function and can be called the same when user clicks on a button. This is simple but very powerful as this can be used a cross-browser snippet.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="javascript javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> emailwindow<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	self.<span style="color: #660066;">location</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'vivek@developersnippets.com'</span>;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://developersnippets.com/2008/10/19/open-e-mail-message-window-onclick-of-a-button-using-javascript/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Free JavaScript database for your browser, Taffy DB</title>
		<link>http://developersnippets.com/2008/10/19/free-javascript-database-for-your-browser-taffy-db/</link>
		<comments>http://developersnippets.com/2008/10/19/free-javascript-database-for-your-browser-taffy-db/#comments</comments>
		<pubDate>Sun, 19 Oct 2008 11:33:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Ajax]]></category>

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

		<category><![CDATA[Ext JS]]></category>

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

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

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

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

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

		<guid isPermaLink="false">http://developersnippets.com/?p=332</guid>
		<description><![CDATA[Taffy DB, which is well known JavaScript database for your browser, and which is a free and opensource JavaScript Library which acts as a thin layer inside Web 2.0 and Ajax applications.
Unique features are:

* Under 10K!
* Simple, JavaScript Centric Syntax
* Fast
* Easy to include in any web application
* Compatible with major Ajax libraries: YUI, JQuery, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://taffydb.com/" title="Taffy DB">Taffy DB</a>, which is well known JavaScript database for your browser, and which is a free and opensource JavaScript Library which acts as a thin layer inside Web 2.0 and <a href="http://developersnippets.com/2007/05/19/snippet-code-for-simple-ajax-tabs-with-cool-css-styles/" title="Snippet Code for Simple Ajax Tabs with cool CSS Styles">Ajax applications</a>.<span id="more-332"></span><br />
<strong>Unique features are:</strong></p>
<blockquote><p>
* Under 10K!<br />
* Simple, JavaScript Centric Syntax<br />
* Fast<br />
* Easy to include in any web application<br />
* Compatible with major Ajax libraries: YUI, JQuery, Dojo, Prototype, EXT, etc<br />
* CRUD Interface (Create, Read, Update, Delete)<br />
* Sorting<br />
* Looping<br />
* Advanced Queries
</p>
</blockquote>
<p>We can think this as a SQL database in our web browser. If you would like to know more about the same then please do have a look at here - <a href="http://taffydb.com/index.cfm?oa=gettingstarted" title="Getting Started">Getting Started</a><br />
Below are the few example snippets on how we are going to implement and utilize the same:<br />
<strong>Example #1: </strong><br />
Let&#8217;s say you have a collection of products and you want to find every product that costs less $10 and is a book. Simple, just write some JavaScript:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript javascript" style="font-family:monospace;">products.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>price<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>lessthan<span style="color: #339933;">:</span><span style="color: #CC0000;">10</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>type<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;Book&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</pre></td></tr></table></div>

<p><strong>Example #2:</strong><br />
Let&#8217;s say you want to update every product from XZYDesign and set the status to not available:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript javascript" style="font-family:monospace;">products.<span style="color: #660066;">update</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #000066;">status</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;NA&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span>manufacturer<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;XZYDesign&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</pre></td></tr></table></div>

<p><strong>Example #3:</strong><br />
Let&#8217;s say you want to sort your products based on type, price descending, and quantity descending:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript javascript" style="font-family:monospace;">products.<span style="color: #660066;">orderBy</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;type&quot;</span><span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;price&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;desc&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;quantity&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;desc&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>;</pre></td></tr></table></div>

<p>If you would like to know more about the same then please do have a look at here - <a href="http://taffydb.com/index.cfm?oa=gettingstarted" title="Getting Started">Getting Started</a></p>
<p><a href="http://taffydb.com/index.cfm?oa=download" title="Download Taffy DB">Download Taffy DB</a><br />
<a href="http://taffydb.com/index.cfm?oa=feedback" title="Feedback/Bugs">Feedback/Bugs</a><br />
<a href="http://taffydb.com/index.cfm?oa=faq" title="FAQ">FAQ</a></p>
<p>Articles which you would like to read:<br />
<a href="http://developersnippets.com/2008/08/31/system-error-1072896658-in-ie/" title="System Error: -1072896658 in IE">System Error: -1072896658 in IE</a><br />
<a href="http://developersnippets.com/2008/08/16/simple-steps-to-develop-ajax-website-%e2%80%93-developersnippets/" title="Simple steps to develop AJAX Website – DeveloperSnippets">Simple steps to develop AJAX Website – DeveloperSnippets</a><br />
<a href="http://developersnippets.com/2007/05/19/snippet-code-for-simple-ajax-tabs-with-cool-css-styles/" title="Snippet Code for Simple Ajax Tabs with cool CSS Styles">Snippet Code for Simple Ajax Tabs with cool CSS Styles</a><br />
<a href="http://developersnippets.com/2007/05/14/a-simple-snippet-code-to-learn-basics-of-ajax/" title="A simple snippet code to learn basics of Ajax">A simple snippet code to learn basics of Ajax</a></p>
]]></content:encoded>
			<wfw:commentRss>http://developersnippets.com/2008/10/19/free-javascript-database-for-your-browser-taffy-db/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Code Snippet for creating custom Flash CS3 Preloader</title>
		<link>http://developersnippets.com/2008/09/28/code-snippet-for-creating-custom-flash-cs3-preloader/</link>
		<comments>http://developersnippets.com/2008/09/28/code-snippet-for-creating-custom-flash-cs3-preloader/#comments</comments>
		<pubDate>Sun, 28 Sep 2008 18:46:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Action Scripting]]></category>

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

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

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

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

		<category><![CDATA[ActionScript 3]]></category>

		<category><![CDATA[Adobe Flash CS3]]></category>

		<guid isPermaLink="false">http://developersnippets.com/?p=286</guid>
		<description><![CDATA[As you guys already know that Adobe Flash CS3 is awesome enough, in CS3 we can see more features and especially coming to ActionScripting, more OOPS concepts has been introduced. Compared to old versions of flash ActionScripting, now experts says that Flash CS3 is good enough to handle more with Classes and Objects using OOPS [...]]]></description>
			<content:encoded><![CDATA[<p>As you guys already know that Adobe Flash CS3 is awesome enough, in CS3 we can see more features and especially coming to ActionScripting, more OOPS concepts has been introduced. Compared to old versions of flash ActionScripting, now experts says that Flash CS3 is good enough to handle more with Classes and Objects using OOPS concepts.</p>
<p>Coming to our topic today, after going through this post you will get an idea of how we can create a Custom Flash CS3 Preloader.<span id="more-286"></span></p>
<p>Custom preloader is a must topic in all aspects while creating any application in Flash or while doing any animation using Flash. The process is much different in ActionScript 3.0 compared to older versions of Action Scripting. External files are no longer loaded on to the stage like you might have done in earlier versions of Flash. Creating a Custom Flash CS3 Preloader is simple and very easy to implement. Here we will be creating a preloader which can be used for loading external images or other SWF (acronym of &quot;<strong>Shockwave Flash</strong> &quot;) files.</p>
<p>Before start creating the same, initially please do download the respective files – since this going to help us in understanding the same. Please do <strong><a href="http://www.developersnippets.com/FlashExamples/FlashCS3/flashpreloader.zip" title="FlashPreloader">download</a></strong> the example files for reference, after downloading please do open <strong>flashpreloader.fla</strong> file.</p>
<p><strong>Getting Started:</strong></p>
<p><strong>Step 1. Open flashpreloader.fla</strong></p>
<p>After opening the <strong>flashpreloader.fla</strong> file, please do review its contents, you will see that the stage is empty. This is because here we are going to load an external file and display the same here. Here we are going to use some code to dynamically place the preloader on the stage and to remove the same from the stage when the loading is complete.</p>
<p>Press <strong>Ctrl+L</strong> to open the respective Library; here you will see two movie clips that is <strong>rectBarMC </strong> and Preloader Movie Clips. <strong>rectBarMC </strong> is simple blue rectangle bar which will be used to create a visual progress bar when a file is loading.</p>
<p><img style="border: 0;" src="http://developersnippets.com/wp-content/uploads/2008/09/library.jpg" alt="Library" width="241" height="357" /></p>
<p>Firstly we will go with <strong>rectBarMC </strong> as I have mentioned above this is a simple rectangle bar which will be used as a progress bar for our program.</p>
<p>And coming to <strong>Preloader</strong> , which is a movie clip contain all the respective pieces of our preloader like the text “<strong>Loading 100%</strong> ” etc., Just right click on the same and check for the linkage option in the context menu. When you click on Linkage, it will open up “<strong>Linkage Properties</strong> ” window, in that window make sure that <strong>Class name </strong> should match with the movie clip name like “<strong>Preloader</strong> ” for this the <strong>Base class </strong> would be “<strong>flash.display.MovieClip</strong> ”. And if you see the checkbox for <strong>Export for ActionScript</strong> has been selected, this means that when the respective file runs, we can access this movie clip dynamically by its class name that is here “<strong>Preloader</strong> ”. Below is the screen shot which resembles the same – <strong>linkage properties</strong></p>
<p><img style="border: 0;" src="http://developersnippets.com/wp-content/uploads/2008/09/linkageproperties.jpg" alt="Linkage Properties" width="449" height="235" /><br />
The Linkage properties for the Preloader Movie Clip.</p>
<p>Now just open the <strong>Preloader</strong> Movie Clip by double clicking on it in the library. Here you can see three respective layers which are named as <strong>Loading_txt</strong> , <strong>Loading_bar </strong> and <strong>Border_frame</strong> .</p>
<p>“<strong>Loading_txt</strong> ” layer just contains the “<strong>Loading 100%</strong> ” text that tells the user what percentage of the respective file has been downloaded. And when you select the same, in the properties inspector panel, you can see that <strong>loading_txt</strong> has given as the <strong>instance name</strong> . Using ActionScripting code we can show how much amount of file has been loaded.</p>
<p>“<strong>Loading_bar</strong> ” Layer contains an instance of the <strong>rectBarMC</strong> movie clip which will expand to visually indicate how much of the file has been downloaded or completed. And for this we have given an instance name as <strong>rectbar_mc</strong> .</p>
<p>“<strong>Border_frame</strong> ” Layer just it contains the box shape, it looks like a border.</p>
<p>Below snap-shot resembles the Preloader Movie Clip.</p>
<p><img style="border: 0;" src="http://developersnippets.com/wp-content/uploads/2008/09/preloadermovieclip.jpg" alt="Preloader Movie Clip" width="482" height="163" /></p>
<p><strong>Step 2. Adding ActionScript to load the external file:</strong></p>
<p>Now we will try to add ActionScript to load the external file, click on the <strong>Scene 1</strong> under the timeline. You can see one layer called as “<strong>actions</strong> ”. Select the “<strong>actions</strong> ” layer and press <strong>F9</strong> to open the <strong>Actions panel</strong> . Here we will be loading an external <strong>.swf </strong> file, keeping this in mind we will write some ActionScript code. Just go through the code snippet below which I have written for loading an external <strong>.swf</strong> file.</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
</pre></td><td class="code"><pre class="actionscript3 actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> myUrlReq<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">URLRequest</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLRequest</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;externalfile.swf&quot;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #6699cc; font-weight: bold;">var</span> myLoader<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Loader</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Loader</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
myLoader.<span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span>myUrlReq<span style="color: #000000;">&#41;</span>;
&nbsp;
myLoader.<span style="color: #004993;">contentLoaderInfo</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">OPEN</span>,showPreloader<span style="color: #000000;">&#41;</span>;
myLoader.<span style="color: #004993;">contentLoaderInfo</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">ProgressEvent</span>.<span style="color: #004993;">PROGRESS</span>,showProgress<span style="color: #000000;">&#41;</span>;
myLoader.<span style="color: #004993;">contentLoaderInfo</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">COMPLETE</span>,showContent<span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #6699cc; font-weight: bold;">var</span> myPreloader<span style="color: #000000; font-weight: bold;">:</span>Preloader = <span style="color: #0033ff; font-weight: bold;">new</span> Preloader<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #339966; font-weight: bold;">function</span> showPreloader<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
        <span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>myPreloader<span style="color: #000000;">&#41;</span>;
        myPreloader.<span style="color: #004993;">x</span> = <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageWidth</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span>;
        myPreloader.<span style="color: #004993;">y</span> = <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageHeight</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span>;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #339966; font-weight: bold;">function</span> showProgress<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">ProgressEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
        <span style="color: #6699cc; font-weight: bold;">var</span> percentLoaded<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = event.<span style="color: #004993;">bytesLoaded</span><span style="color: #000000; font-weight: bold;">/</span>event.<span style="color: #004993;">bytesTotal</span>;
        myPreloader.loading_txt.<span style="color: #004993;">text</span> = <span style="color: #990000;">&quot;Loading - &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #004993;">Math</span>.<span style="color: #004993;">round</span><span style="color: #000000;">&#40;</span>percentLoaded <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">100</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #990000;">&quot;%&quot;</span>;
        myPreloader.rectbar_mc.<span style="color: #004993;">width</span> = <span style="color: #000000; font-weight:bold;">198</span> <span style="color: #000000; font-weight: bold;">*</span> percentLoaded;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #339966; font-weight: bold;">function</span> showContent<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
        <span style="color: #004993;">removeChild</span><span style="color: #000000;">&#40;</span>myPreloader<span style="color: #000000;">&#41;</span>;
        <span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>myLoader<span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p><strong>Code in Brief:</strong></p>
<p><strong>1. Loading the External file</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="actionscript3 actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> myUrlReq<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">URLRequest</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLRequest</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;externalfile.swf&quot;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #6699cc; font-weight: bold;">var</span> myLoader<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Loader</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Loader</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
myLoader.<span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span>myUrlReq<span style="color: #000000;">&#41;</span>;</pre></td></tr></table></div>

<p>Here in the above snippet code, we are creating an object of URLRequest called myUrlReq and will be creating an object of Loader called myLoader, and this Loader class expects to receive a URLRequest pointing to the file you wish to load, it can be an image file / any external file which you want to load. Here we are loading an external .swf file with file name as “externalfile.swf”.</p>
<p><strong>2. Creating respective Listeners to check the progress of the file</strong></p>
<p>After that we need to create listeners to monitor the progress of the file, like how much amount of the file has been loaded till now. For that we will be using event listeners like <strong>Event.OPEN</strong> , <strong>ProgressEvent.PROGRESS</strong> , <strong>Event.COMPLETE</strong>.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="actionscript3 actionscript3" style="font-family:monospace;">myLoader.<span style="color: #004993;">contentLoaderInfo</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">OPEN</span>,showPreloader<span style="color: #000000;">&#41;</span>;
myLoader.<span style="color: #004993;">contentLoaderInfo</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">ProgressEvent</span>.<span style="color: #004993;">PROGRESS</span>,showProgress<span style="color: #000000;">&#41;</span>;
myLoader.<span style="color: #004993;">contentLoaderInfo</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">COMPLETE</span>,showContent<span style="color: #000000;">&#41;</span>;</pre></td></tr></table></div>

<p>Firstly we will run a function called <strong>showPreloader()</strong> which will place the Preloader movie clip on the stage. Then Secondly we will run a function called <strong>showProgress()</strong> which will visually update the preloader bar and text to reflect the download progress. Finally we will run a function called <strong>showContent()</strong> , which will remove the preloader and show the respective content once the download is complete.</p>
<p><strong>3. showPreloader()</strong></p>
<p>Before running the respective function, we need to create an instance of the <strong>Preloader </strong> movie clip which will display the <strong>Preloader </strong> on the stage.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="actionscript3 actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> myPreloader<span style="color: #000000; font-weight: bold;">:</span>Preloader = <span style="color: #0033ff; font-weight: bold;">new</span> Preloader<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
Then write the <span style="color: #004993;">code</span> of the respective <span style="color: #339966; font-weight: bold;">function</span> showPreloader<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span>
&nbsp;
<span style="color: #339966; font-weight: bold;">function</span> showPreloader<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>myPreloader<span style="color: #000000;">&#41;</span>;
myPreloader.<span style="color: #004993;">x</span> = <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageWidth</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span>;
myPreloader.<span style="color: #004993;">y</span> = <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageHeight</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span>;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Using <strong>addChild()</strong> we are placing <strong>myPreloader </strong> instance on the stage, if you see the above code we are placing the respective preloader in the center of the stage through<strong> x</strong> and <strong>y</strong> positions.</p>
<p><strong>4. showProgress()</strong></p>
<p>Now after completion of the positioning of the preloader, now we will call <strong>showProgress()</strong> function, here in this function we will calculate the percentage of loading completed by dividing the number of bytes downloaded so far by the total number of bytes. Then after calculating we are assigning the same to the <strong>loading_txt</strong> . And simultaneously we need to increase the width of the <strong>rectbar_mc</strong> to visually showing the same to the user that this much amount of file has been loaded.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="actionscript3 actionscript3" style="font-family:monospace;"><span style="color: #339966; font-weight: bold;">function</span> showProgress<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">ProgressEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> percentLoaded<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = event.<span style="color: #004993;">bytesLoaded</span><span style="color: #000000; font-weight: bold;">/</span>event.<span style="color: #004993;">bytesTotal</span>;
	myPreloader.loading_txt.<span style="color: #004993;">text</span> = <span style="color: #990000;">&quot;Loading - &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #004993;">Math</span>.<span style="color: #004993;">round</span><span style="color: #000000;">&#40;</span>percentLoaded <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">100</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #990000;">&quot;%&quot;</span>;
	myPreloader.bar_mc.<span style="color: #004993;">width</span> = <span style="color: #000000; font-weight:bold;">198</span> <span style="color: #000000; font-weight: bold;">*</span> percentLoaded;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p><strong>5. showContent()</strong></p>
<p>After loading everything, we need to remove the movie clip from the stage and need to show the external file respectively. Below is the code for the same.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="actionscript3 actionscript3" style="font-family:monospace;"><span style="color: #339966; font-weight: bold;">function</span> showContent<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #004993;">removeChild</span><span style="color: #000000;">&#40;</span>myPreloader<span style="color: #000000;">&#41;</span>;
	<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>myLoader<span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>The above function is called after completion of <strong>showProgress()</strong> , and in this function we are removing <strong>myPreloader </strong> movie clip and adding the external file on the stage that is <strong>myLoader </strong> (I mean an external file named as <strong>externalflash.swf</strong> ).</p>
<p>So, we are done with the preloader. Now test the application by pressing <strong>Ctrl+Enter</strong> you can see preloader in action. Before pressing Ctrl+Enter, please do include some .swf file and instead of &#8220;externalflash.swf&#8221; place your own file in the same directory. After placing the file then press Ctrl+Enter for better results or else it will give an error like &#8220;URL not Found&#8221;.</p>
<p><strong>Download</strong><br />
<a href="http://www.developersnippets.com/FlashExamples/FlashCS3/flashpreloader.zip" title="FlashPreloader">Flash Preloader</a></p>
]]></content:encoded>
			<wfw:commentRss>http://developersnippets.com/2008/09/28/code-snippet-for-creating-custom-flash-cs3-preloader/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
