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

<channel>
	<title>Is Good Stuff &#187; Useful Scripts</title>
	<atom:link href="http://www.isgoodstuff.com/tag/useful-scripts/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.isgoodstuff.com</link>
	<description>All the good stuff here!</description>
	<lastBuildDate>Mon, 30 Jan 2012 01:31:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
		<item>
		<title>Titanium Appcelerator &#8211; Snippets Tutorial</title>
		<link>http://www.isgoodstuff.com/2011/12/21/titanium-appcelerator-tutorial-making-snippets-bundle/</link>
		<comments>http://www.isgoodstuff.com/2011/12/21/titanium-appcelerator-tutorial-making-snippets-bundle/#comments</comments>
		<pubDate>Wed, 21 Dec 2011 00:02:55 +0000</pubDate>
		<dc:creator>Alex T.</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[Mobile Development]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Useful Scripts]]></category>

		<guid isPermaLink="false">http://www.isgoodstuff.com/?p=2094</guid>
		<description><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/et_temp/modified-83203_300x180.png"/></p>Short tutorial on how to write your own snippets using Titanium Appcelerator. ]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/et_temp/modified-83203_300x180.png"/></p><p>Today, I&#8217;m gonna write a short tutorial on how to write your own snippet using Titanium Appcelerator. What are snippets you say? Well a code snippet is a programming term for a small region of re-usable source <em>code</em>, machine<em>code</em> or text. Normally snippets when defined into an IDE or editor (thats supports em) will appear in autocompletion / auto assist when users are typing in a snippet like <strong>trigger word.</strong> For example, if you have a snippet that triggers from the word &#8220;info&#8221;, just by typing <strong>info</strong>, the auto assist popup will appear suggesting user to use the code snippet.</p>
<p style="text-align: center;"><a href="http://www.watchlearnknow.com/wp-content/uploads/2011/12/Screen-Shot-2011-12-21-at-6.58.07-AM.png"><img class="aligncenter" style="margin-top: 15px; margin-bottom: 15px;" title="Screen Shot 2011-12-21 at 6.58.07 AM" src="http://www.watchlearnknow.com/wp-content/uploads/2011/12/Screen-Shot-2011-12-21-at-6.58.07-AM.png" alt="" width="500" height="192" vspace="15" /></a></p>
<p>Snippets are very useful and should always be shared or placed in a common and centralized place like <a href="http://www.dropbox.com">dropbox</a>, somewhere in the net I find it easier to access as I travel from workplace to another. Not only this improves your coding speed but also improves your quality output by reducing error made in typos and such. I have a general rule of making a snippet, if the code is so useful and you find yourself repeatingly using it.. then, please code it into a snippet bundle.</p>
<p>Titanium Appcelerator is an IDE modified fork from the IDE called Aptana IDE. They both support ruby like bundle as their snippet programming language. For those using Aptana IDE, I think this tutorial works for that IDE as well. To write snippet bundle scripts, one needs to learn a little bit of ruby code. Don&#8217;t worry is not that hard only a few lines to get things done &#8211; in fact you can just copy paste code from here then modify the parameters if you like. Some important note to remember before starting&#8230;</p>
<ul>
<ul>
<li>First off, we need to know how Titanium Appcelerator accesses it Snippet Bundle Source File. It is always located at your Users <strong>/documents/Aptana Rubles/</strong> folder. This folder will be created once, you installed Titanium Appcelerator.</li>
<li>You also need to enable the bundle Viewer. This allows you to <strong>check to see if your snippet bundle is successfully &#8220;recognized&#8221; by the IDE</strong> and that there&#8217;s no error in the lines of code which prevents the snippet from triggering. Follow steps below to enable the Viewer.</li>
<ol>
<li>Go to <strong>Window &gt; Show View &gt; Other&#8230;</strong></li>
<li>Expand the Studio category</li>
<li>Select the <strong>Bundles</strong> item<br />
A view appears showing all currently loaded bundles</li>
<li>You should see the bundle with the name you gave above in the list</li>
<li>For detailed information on selected items in the Bundles View, go to <strong>Window &gt; Show View &gt; Other&#8230;</strong></li>
<li>Expand the General category</li>
<li>Select the <strong>Properties</strong> item<br />
A view appears showing detailed information on your Bundles View selection</li>
<li>If your bundle has an error, you should see output in the Console view.</li>
</ol>
<li>Next just Create a folder, in <strong>/documents/Aptana Rubles/ &lt;your snippet folder name &#8211; anyname of your choice&gt; , </strong> and a ruby file called <strong>bundle.rb</strong> inside this folder.</li>
</ul>
</ul>
<p>Start by adding this code to your bundle.rb file. Code below shows, the &#8220;definition of your snippet group&#8221;. Notice, that once you save your file, it will appear somewhere in the bundle viewer, (sorted in alphabetical order).</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">require <span style="color: #3366CC;">'ruble'</span>
&nbsp;
bundle <span style="color: #000066; font-weight: bold;">do</span> <span style="color: #339933;">|</span>bundle<span style="color: #339933;">|</span>
  bundle.<span style="color: #660066;">display_name</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'My Snippets'</span>
end</pre></div></div>

<ul>
<ul>
<li>Next, let&#8217;s add the code Titanium.API.info(something) into our snippet, since we also use that for displaying stuff in console.</li>
</ul>
</ul>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">snippet <span style="color: #3366CC;">&quot;API Info&quot;</span> <span style="color: #000066; font-weight: bold;">do</span> <span style="color: #339933;">|</span>snip<span style="color: #339933;">|</span>
  snip.<span style="color: #660066;">trigger</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;API.info&quot;</span>
  snip.<span style="color: #660066;">expansion</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;Titanium.API.info(${1:variable});&quot;</span>
end</pre></div></div>

<ul>
<li><strong>snip.trigger</strong>, is what the IDE is constantly looking for to trigger this snippet. In my case, I wanted the snippet to appear once, I type <strong>API.info</strong>.</li>
<li><strong>snip.expansion</strong> is where all your actual snippet code will be.Notice I added ${} into the code, this means to place the cursor within after inserting, and <strong>1:variable</strong> the word &#8220;<strong>variable</strong>&#8221; can be anything you defined it to be, is <strong>just for your reference and it will appear in code assist</strong> and the <strong>number 1</strong> means is expecting 1st input, if there&#8217;s more than one, just add in another number, the IDE will jump from another variable input to another after user hits enter. However these are optional and most of the snippets doesn&#8217;t even need an input parameter assist.</li>
<li>To add new snippet simply, add copy paste the <strong>snippet &#8220;API Info&#8221; do&#8230;</strong> to <strong>end</strong> line to a new line and modify from there</li>
<li>Last thing you should know about snippet is that, sometimes, they failed to load and this may due to cache file corrupted. This cache is created automatically, by IDE. To clear the cache of the snippet file, just move the cache.yml to the trash and relaunch the IDE.</li>
</ul>
<p><a href="http://www.isgoodstuff.com/wp-content/uploads/2011/12/Screen-Shot-2011-12-21-at-7.38.02-AM.png"><img class="aligncenter size-full wp-image-2103" title="Screen Shot 2011-12-21 at 7.38.02 AM" src="http://www.isgoodstuff.com/wp-content/uploads/2011/12/Screen-Shot-2011-12-21-at-7.38.02-AM.png" alt="" width="444" height="167" /></a></p>
<p>I hope this tutorial helps you titanium developers out there, to speed up your development to at least 3 fold haha as it did to mine. CODE STRONG! Happy holidays and have a great year ahead!</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.isgoodstuff.com/2011/12/21/titanium-appcelerator-tutorial-making-snippets-bundle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AS3  Simple Loader for External Image</title>
		<link>http://www.isgoodstuff.com/2011/11/15/as3-simple-loader-for-external-image/</link>
		<comments>http://www.isgoodstuff.com/2011/11/15/as3-simple-loader-for-external-image/#comments</comments>
		<pubDate>Tue, 15 Nov 2011 04:22:09 +0000</pubDate>
		<dc:creator>Alex T.</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Useful Scripts]]></category>

		<guid isPermaLink="false">http://www.isgoodstuff.com/?p=1988</guid>
		<description><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/2011/11/thumbB.png"/></p>Simple package script to load an external image using Loader Class.]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/2011/11/thumbB.png"/></p><p style="text-align: justify;">Today&#8217;s tutorial, I&#8217;m covering on how to write a simple Loader class in AS3 to load external image. Why the hassle? Well loader Class is useful to load lots of stuff, image being one of em &#8211; loading externally thus, swf size is reduced.</p>
<p style="text-align: justify;">You can then design your movieclip with nice spinning preloader animation while waiting for image to load externally. See swf below is the sample.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package  
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #808080; font-style: italic;">// Importing all the class needed for the job.</span>
        <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #0066CC;">MovieClip</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Loader</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">Event</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">net</span>.<span style="color: #006600;">URLRequest</span>;
	<span style="color: #808080; font-style: italic;">/**
	 * Description : A Simple Class to Load External Images.
	 * URL : http://www.isgoodstuff.com
	 * @author Alex T.
	 **/</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #0066CC;">extends</span> <span style="color: #0066CC;">MovieClip</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> mcPreloader:<span style="color: #0066CC;">MovieClip</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> mcContainer:<span style="color: #0066CC;">MovieClip</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> myImgLoader:Loader = <span style="color: #000000; font-weight: bold;">new</span> Loader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Main<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> 
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #808080; font-style: italic;">// Inside the flas contains two onStage movieClip named mcPreloader and mcContainer.</span>
			<span style="color: #808080; font-style: italic;">// Once the image is loaded, mcPreloader will disappear and mcContainer will be used</span>
			<span style="color: #808080; font-style: italic;">// to contain the new image. (Jessica Alba's Pic)</span>
			myImgLoader.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;http://www.isgoodstuff.com/wp-content/uploads/2011/11/sample.png&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
			myImgLoader.<span style="color: #006600;">contentLoaderInfo</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>, handleLoadCompleted<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleLoadCompleted<span style="color: #66cc66;">&#40;</span>evt:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
			mcPreloader.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">false</span>;
			<span style="color: #808080; font-style: italic;">// Once loaded, you can set it's height and width</span>
			myImgLoader.<span style="color: #0066CC;">width</span> = <span style="color: #cc66cc;">300</span>;
			myImgLoader.<span style="color: #0066CC;">height</span> = <span style="color: #cc66cc;">300</span>;
			mcContainer.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span> myImgLoader <span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p align="center"><object width="300" height="300" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.isgoodstuff.com/wp-content/uploads/2011/11/simpleLoader.swf" /><embed width="300" height="300" type="application/x-shockwave-flash" src="http://www.isgoodstuff.com/wp-content/uploads/2011/11/simpleLoader.swf" /></object></p>
<p>For Today&#8217;s Tutorial click on the link below&#8230;<br />
<p><strong><a href="http://www.isgoodstuff.com/wp-content/plugins/download-monitor/download.php?id=26">Download Here</a></strong></p></br></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.isgoodstuff.com/2011/11/15/as3-simple-loader-for-external-image/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>WTH is Encapsulating Javascript?</title>
		<link>http://www.isgoodstuff.com/2011/10/16/wth-is-encapsulating-javascript/</link>
		<comments>http://www.isgoodstuff.com/2011/10/16/wth-is-encapsulating-javascript/#comments</comments>
		<pubDate>Sun, 16 Oct 2011 00:16:27 +0000</pubDate>
		<dc:creator>Alex T.</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Useful Scripts]]></category>

		<guid isPermaLink="false">http://www.isgoodstuff.com/?p=1919</guid>
		<description><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/2011/10/JavaScript-Web.png"/></p>Your javascript in a neater way, more than a function, less than a traditional OOP class.]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/2011/10/JavaScript-Web.png"/></p><p style="text-align: justify;">Over the weekend, I&#8217;ve been doing javascripting and some one messaged me on how to write an <em>encapsulating javascript functions</em> which is a common practice in web development nowadays. Especially when we involved in <strong>mobile where memory and processor is critical</strong></p>
<blockquote>
<p style="text-align: justify;">I remember around 8 years ago when, javascript was just a simple procedural language used for web development then it evolved into DHTML which we can use to make cool effects. Later, comes AJAX and wonderful js frameworks we had today.</p>
<p><BR></p>
<p style="text-align: justify;">Today this script language evolved into some kind of <em>magical development language of wonders</em> &#8211; you can even write a full mobile to desktop app using this scripting language with the help of cross compilers.</p>
</blockquote>
<p>Because of that, developing a javascript application can lead to complex scripting due to huge number of variables and objects you control.</p>
<p>Therefore for best practice sake,</p>
<ol>
<li style="text-align: justify;">You need to keep your javascript functions in main webpage <strong>as minimal as possible and js files must be as human readable as possible</strong>. e.g. &lt;script src=&#8221;calculate.js&#8221;&gt;&lt;/script&gt; should at least have calculate related functions in it like <em> &#8221;calculate.sum( myNumberList );&#8221;</em> so that, is easy to use calculate.js like an util file.</li>
<li style="text-align: justify;"><strong>Don&#8217;t pollute the global scope!</strong> &#8211; A complex javascript script will have alot of variable flowing everywhere thus polluting the global scope and making it easier to read. (this means, we don&#8217;t overuse var VariableName everywhere in our js file &#8211; put in an encapsulated js instead) To control that, we use encapsulated function. An Encapsulated function are  more than a function, less than a traditional OOP class but better than nothing <img src='http://www.isgoodstuff.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  .</li>
<li>There&#8217;s several ways I found can achieve this but, I&#8217;m gonna list this one first because is one of my favorites.</li>
</ol>
<div>Method one, encapsulating js using namespace and self-triggering function.</div>
<blockquote>
<p style="text-align: justify;">What is a self-triggering function?, Self -triggering function is a function construct which fires straightaway. We normally use that for &#8220;container&#8221; &#8211; to contain variables, and related functions.</p>
</blockquote>
<p style="text-align: justify;">Here is how to write a self triggering function,</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><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: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'fired immediately'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Let&#8217;s write a chained self triggering function. Follow the code below.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> trigger <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: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'chained function'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//try calling it using</span>
trigger<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// and compare with</span>
trigger<span style="color: #339933;">;</span></pre></div></div>

<p style="text-align: justify;">Noticed, the behaviour of trigger, is no longer regarded as function in browser. In-fact, if you use trigger(); you will get an error in firebug. Notice also that, when you just call trigger without brackets, and yet it fires the function. This is <strong>how we do our namespace in encapsulating js</strong>.</p>
<p style="text-align: justify;">Let&#8217;s work on other namespace &#8211; this time with proper function, namespace are used to clearly define and separate our javascript so that, same function names and variables don&#8217;t get mixed up. It&#8217;s like writing a class with methods all encapsulated within.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> calc <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: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p style="text-align: justify;">The code above simply creates a function that returns nothing. We normally use this as our <strong>namespace starter/definer</strong>. Then, we proceed further with writing a specific function / method like construct e.g. calc.sum.</p>
<blockquote>
<p style="text-align: justify;">Note calc.sum is undefined, if you do not declare a namespace starter/definer which is a chained self-triggering function in memory that returns nothing.</p>
</blockquote>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">//Secondary Namespace calc.sum - wrapped using self triggering function</span>
calc.<span style="color: #660066;">sum</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: #009966; font-style: italic;">/* private variables only to calc.sum see how variables are kept within */</span>
	<span style="color: #003366; font-weight: bold;">var</span> value1 <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> value2 <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>  
&nbsp;
	<span style="color: #006600; font-style: italic;">// private method to calc.sum</span>
	<span style="color: #003366; font-weight: bold;">function</span> calc<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;">var</span> sum <span style="color: #339933;">=</span> parseInt<span style="color: #009900;">&#40;</span>value1<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> parseInt<span style="color: #009900;">&#40;</span>value2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    <span style="color: #000066; font-weight: bold;">return</span> sum<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">// public functions</span>
	<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#123;</span>
	    init<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>external_value1<span style="color: #339933;">,</span> external_value2<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	         <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">setValue1</span><span style="color: #009900;">&#40;</span>external_value1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	         <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">setValue2</span><span style="color: #009900;">&#40;</span>external_value2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
	    setValue1<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>
	        value1 <span style="color: #339933;">=</span> val<span style="color: #339933;">;</span>
	    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
	    setValue2<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>
	        value2 <span style="color: #339933;">=</span> val<span style="color: #339933;">;</span>
	    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
	    getSum<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;">// calling an internal private function</span>
               <span style="color: #006600; font-style: italic;">// (requires no &quot;this.&quot;)</span>
		<span style="color: #000066; font-weight: bold;">return</span> calc<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    <span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Now, we have a &#8220;class util&#8221; like javascript, and everything is kept within&#8230;isn&#8217;t that neat?</p>
<p>To use, we simply need to init it.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">//init calc.sum which requires two integer,</span>
calc.<span style="color: #660066;">sum</span>.<span style="color: #660066;">init</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">10</span><span style="color: #339933;">,</span><span style="color: #CC0000;">30</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>calc.<span style="color: #660066;">sum</span>.<span style="color: #660066;">getSum</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// should return you 40</span></pre></div></div>

<p>Today&#8217;s tutorial in HTML : <p><strong><a href="http://www.isgoodstuff.com/wp-content/plugins/download-monitor/download.php?id=25">Download Here</a></strong></p></br></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.isgoodstuff.com/2011/10/16/wth-is-encapsulating-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AS3 Collision Detection Kit</title>
		<link>http://www.isgoodstuff.com/2010/03/30/as3-collision-detection-kit/</link>
		<comments>http://www.isgoodstuff.com/2010/03/30/as3-collision-detection-kit/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 00:55:15 +0000</pubDate>
		<dc:creator>Alex T.</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[Useful Scripts]]></category>

		<guid isPermaLink="false">http://www.isgoodstuff.com/?p=565</guid>
		<description><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/et_temp/cdkbigpost-44761_300x200.png"/></p>Collision Detection Kit, a powerful opensource collision detection class, useful for AS3 game development.]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/et_temp/cdkbigpost-44761_300x200.png"/></p><p><a href="http://www.isgoodstuff.com/wp-content/uploads/2009/09/ActionscriptIcon_400_thumb.png"><img class="alignleft size-full wp-image-485" style="margin-right: 8px;" title="ActionscriptIcon_400_thumb.png" src="http://www.isgoodstuff.com/wp-content/uploads/2009/09/ActionscriptIcon_400_thumb.png" alt="" width="124" height="124" /></a>Ever wonder, is there an easier way instead of making loops and check for every hitTest with all sorts of  shapes and sizes? Well, may I present to you &#8211; <a href="http://code.google.com/p/collisiondetectionkit/">Collision Detection Kit</a>!</p>
<div id="_mcePaste">
<p>The Collision Detection Kit is a package of classes created for pixel-precise, shape-based collision detection for all display objects. It is written in Actionscript 3.0 and meant for Flash Player version 9 and higher.</p>
<p>The Collision Detection Kit comes with several features to control how collisions are detected, and provides data for the user of the class so they can do something about the collision:</p>
</div>
<div id="_mcePaste">
<ul>
<li>Set an alpha threshold to ignore colors below the threshold.</li>
<li>Specify colors and color ranges to exclude from collision detection.</li>
<li>Receive an angle of collision for each collision. We&#8217;re not talking about bounding boxes here &#8211; the angle is calculated based on the shapes of the display objects at the site of the collision. Great for when you&#8217;re working with physics!</li>
<li>Receive the pixels that overlapped in a collision in stage coordinates. Combined with the returned angle, and your physics engine will have no problems traversing complicated shapes or performing off-axis rotation.</li>
<li>Takes transformations (scale, rotation, color transforms, etc.) of individual instances of your display objects into account.</li>
<li>Add items for collision detection regardless of their nesting.</li>
<li>You can have as many CollisionGroup and CollisionList instances as you want, allowing you to easily manage different interactions and behaviors.</li>
<li>Works with all display objects &#8211; MovieClips, Sprites, Bitmaps, TextFields, FLVs, and on and on!</li>
</ul>
</div>
<p><span id="more-565"></span></p>
<p>Check out CDK in action below!</p>
<p><object id="Opening" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="550" height="400" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="align" value="middle" /><param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="false" /><param name="quality" value="high" /><param name="bgcolor" value="#ff6600" /><param name="src" value="http://www.isgoodstuff.com/wp-content/uploads/2010/03/Opening.swf" /><param name="name" value="Opening" /><param name="allowfullscreen" value="false" /><embed id="Opening" type="application/x-shockwave-flash" width="550" height="400" src="http://www.isgoodstuff.com/wp-content/uploads/2010/03/Opening.swf" name="Opening" bgcolor="#ff6600" quality="high" allowfullscreen="false" allowscriptaccess="sameDomain" align="middle"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.isgoodstuff.com/2010/03/30/as3-collision-detection-kit/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>AS3 Explosion Burst Effect Class</title>
		<link>http://www.isgoodstuff.com/2010/02/11/as3-explosion-burst-class/</link>
		<comments>http://www.isgoodstuff.com/2010/02/11/as3-explosion-burst-class/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 09:27:11 +0000</pubDate>
		<dc:creator>Alex T.</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[Useful Scripts]]></category>

		<guid isPermaLink="false">http://www.isgoodstuff.com/?p=548</guid>
		<description><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/et_temp/Explosion-249083_300x200.png"/></p>This is the explosion effects class in as3. You can use it in your flash games project.]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/et_temp/Explosion-249083_300x200.png"/></p><p><a href="http://www.isgoodstuff.com/wp-content/uploads/2009/09/ActionscriptIcon_400_thumb.png"><img class="alignleft size-full wp-image-485" style="margin-right: 8px; margin-bottom: 5px;" title="ActionscriptIcon_400_thumb.png" src="http://www.isgoodstuff.com/wp-content/uploads/2009/09/ActionscriptIcon_400_thumb.png" alt="" width="124" height="124" /></a>Developing games like Shooter in As3 can be boring without good explosion effects. Over the weekends, I ported a simple class ( from As2 )which does some randomized explosion movie-clips.</p>
<p>This is to be used when there&#8217;s an explosion in the game. The class allows you to create explosion effect based on number of particles, size of distance and alpha. All you need is to instantiate it and pass in the variables needed. See sample below.</p>
<div><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="500" height="300" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.isgoodstuff.com/wp-content/uploads/2010/02/explosionSystemCS3.swf" /><embed type="application/x-shockwave-flash" width="500" height="300" src="http://www.isgoodstuff.com/wp-content/uploads/2010/02/explosionSystemCS3.swf"></embed></object></div>
<p><span id="more-548"></span></p>
<p>Download the <a href="http://www.isgoodstuff.com/wp-content/files/explosionBurst.zip" target="_blank">source here</a>, when you use make sure you have to use the movie-clip from the library folder as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.isgoodstuff.com/2010/02/11/as3-explosion-burst-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AS3 Flash-Console</title>
		<link>http://www.isgoodstuff.com/2009/12/04/flash-console/</link>
		<comments>http://www.isgoodstuff.com/2009/12/04/flash-console/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 01:59:50 +0000</pubDate>
		<dc:creator>Alex T.</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[Useful Scripts]]></category>

		<guid isPermaLink="false">http://www.isgoodstuff.com/?p=501</guid>
		<description><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/et_temp/flashconsole02-87760_300x200.png"/></p>Looking for a good debugging tool, other than trace in flash right? Look no further.]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/et_temp/flashconsole02-87760_300x200.png"/></p><p><a href="http://www.isgoodstuff.com/wp-content/uploads/2009/12/console_controls01.png"><img class="alignleft size-full wp-image-523" title="console_controls01" src="http://www.isgoodstuff.com/wp-content/uploads/2009/12/console_controls01.png" alt="console_controls01" width="598" height="198" /></a></p>
<p style="text-align: justify;">Every wonder that, there&#8217;s something to display your run-time variables smoothly without using the laggy trace.</p>
<p style="text-align: justify;">Not to say trace command is useless, but at times is much less cpu intensive to debug values especially on enterFrame run time to an on screen textbox instead of using trace.</p>
<p style="text-align: justify;">
<p style="text-align: justify;">
<p style="text-align: justify;">
<p style="text-align: justify;">
<p style="text-align: justify;">
<p style="text-align: justify;">But, lately I stumbled upon a good console interface like debugger called Flash Console in a form of as3 class package!</p>
<p>Aside from the being able to watch your values real time , it also came with various handy feature such as.</p>
<ul>
<li>Command line</li>
<li>Display info/properties checker (known as Roller)</li>
<li>RunTime Measurement Ruler</li>
</ul>
<p>All you need to do is to import the class into your main.as and attach C (the singleton class) method startOnStage.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">import</span> com.<span style="color: #006600;">atticmedia</span>.<span style="color: #006600;">console</span>.<span style="color: #006600;">C</span>;
C.<span style="color: #006600;">startOnStage</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span>, <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// To debug a value</span>
C.<span style="color: #006600;">info</span><span style="color: #66cc66;">&#40;</span>variableName<span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>If you are interested click <a href="http://code.google.com/p/flash-console/">here to get it </a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.isgoodstuff.com/2009/12/04/flash-console/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

