<?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>Howtos &#187; Programming</title>
	<atom:link href="http://howto.isgoodness.com/category/it/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://howto.isgoodness.com</link>
	<description>Stuffs that are worth to mention and worth to know</description>
	<lastBuildDate>Sun, 27 Feb 2011 16:19:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>JQuery Datatable</title>
		<link>http://howto.isgoodness.com/2011/02/jquery-datatable/</link>
		<comments>http://howto.isgoodness.com/2011/02/jquery-datatable/#comments</comments>
		<pubDate>Sun, 27 Feb 2011 16:09:02 +0000</pubDate>
		<dc:creator>Van Nhu</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[datatable]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[json]]></category>

		<guid isPermaLink="false">http://howto.isgoodness.com/?p=584</guid>
		<description><![CDATA[I use to play my faceboook app Chinese poker on my Iphone on my way home from work. My connection is not fast enough and it made the game less interest. . I felt also a litle bit frustrated. I need to do something about it and out comes JQuery Datatable. JQuery Datatable generates a [...]]]></description>
			<content:encoded><![CDATA[<p>I use to play my faceboook app <a href="http://apps.facebook.com/xap-xam">Chinese poker</a> on my Iphone on my way home from work. My connection is not fast enough and it made the game less interest. . I felt also a litle bit frustrated. I need to do something about it and out comes JQuery Datatable.</p>
<p>JQuery Datatable generates  a table based on a set of json data. You can provide callback for formatting the content in each td cell, parse attributes to the table, th and td element. You can also add listeners to do more thing on the rendered table. The good thing of this is that I just save 40% bandwidth. The bad thing is that I am still using table.</p>
<p>JQuery Datatable is available at <a href="http://facebook.chinesepoker.isgoodness.com/js/jdatatable.js">http://facebook.chinesepoker.isgoodness.com/js/jdatatable.js</a></p>
]]></content:encoded>
			<wfw:commentRss>http://howto.isgoodness.com/2011/02/jquery-datatable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JQuery history</title>
		<link>http://howto.isgoodness.com/2011/02/jquery-history/</link>
		<comments>http://howto.isgoodness.com/2011/02/jquery-history/#comments</comments>
		<pubDate>Fri, 11 Feb 2011 12:59:09 +0000</pubDate>
		<dc:creator>Van Nhu</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[hash url]]></category>
		<category><![CDATA[history]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[pushState]]></category>
		<category><![CDATA[window]]></category>

		<guid isPermaLink="false">http://howto.isgoodness.com/?p=501</guid>
		<description><![CDATA[Was curious on how window.history.pushState works and since I have been used jQuery history plugin on my Facebook application for years (Thanks to Taku Sano, Takayuki Miwa, Lincoln Cooper!) and still ran on an old version I decided to add support for new feature in HTML5 and rewrite it a litle bit. How does pushState [...]]]></description>
			<content:encoded><![CDATA[<p>Was curious on how window.history.pushState works and since I have been used jQuery history plugin on <a href="http://apps.facebook.com/xap-xam/">my Facebook application</a> for years (Thanks to Taku Sano, Takayuki Miwa, Lincoln Cooper!) and still ran on an old version I decided to add support for new feature in HTML5 and rewrite it a litle bit. How does pushState work? shortly it replaces the entire url with a new url in the url bar without causing the browser to load the actual page. It seems to work great with my application since there is a context switch, no change needs to be done. However, I wonder how much job need to be done (to handle url-sharing or when user push on refresh-button) if the content corresponding to the hash does not have a full page version.</p>
<p>Anyway, here it is. Feel free to use and the usage is simple. There are 2 public methods that you can make call</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">void</span> init<span style="color: #009900;">&#40;</span> callback <span style="color: #009900;">&#91;</span><span style="color: #339933;">,</span> options<span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span>
   initiate history object
<span style="color: #339933;">@</span>param callback <span style="color: #339933;">&lt;</span>Function<span style="color: #339933;">&gt;</span>
  <span style="color: #000066; font-weight: bold;">This</span> <span style="color: #003366; font-weight: bold;">function</span> vill be called <span style="color: #000066; font-weight: bold;">with</span> the hash <span style="color: #000066; font-weight: bold;">as</span> argument when the hash <span style="color: #000066; font-weight: bold;">is</span> updated
<span style="color: #339933;">@</span>param options <span style="color: #339933;">&lt;</span>Object<span style="color: #339933;">&gt;</span> 
   Possible properties 
   <span style="color: #009900;">&#123;</span>noHash<span style="color: #339933;">:</span> Boolean<span style="color: #339933;">,</span> dynamic<span style="color: #339933;">:</span> Boolean<span style="color: #339933;">,</span> initReload<span style="color: #339933;">:</span> Boolean<span style="color: #339933;">,</span> shorten<span style="color: #339933;">:</span> Boolean<span style="color: #009900;">&#125;</span>
   <span style="color: #000066; font-weight: bold;">If</span> noHash <span style="color: #000066; font-weight: bold;">is</span> <span style="color: #003366; font-weight: bold;">true</span> pushState will be used <span style="color: #000066; font-weight: bold;">if</span> it <span style="color: #000066; font-weight: bold;">is</span> available.
   <span style="color: #000066; font-weight: bold;">If</span> dynamic <span style="color: #000066; font-weight: bold;">is</span> <span style="color: #003366; font-weight: bold;">true</span> a callback <span style="color: #000066; font-weight: bold;">is</span> always made even <span style="color: #000066; font-weight: bold;">if</span> it <span style="color: #000066; font-weight: bold;">is</span> the same hash
   <span style="color: #000066; font-weight: bold;">if</span> initReload <span style="color: #000066; font-weight: bold;">is</span> <span style="color: #003366; font-weight: bold;">true</span> the full page will be reload <span style="color: #000066; font-weight: bold;">if</span> the user 
   enters the page <span style="color: #000066; font-weight: bold;">with</span> a hash 
   <span style="color: #000066; font-weight: bold;">If</span> shorten <span style="color: #000066; font-weight: bold;">is</span> <span style="color: #003366; font-weight: bold;">true</span> scheme and host will be removed from the hash.
   <span style="color: #000066; font-weight: bold;">This</span> <span style="color: #000066; font-weight: bold;">is</span> useful when using load directly on href
   <span style="color: #003366; font-weight: bold;">Default</span> <span style="color: #000066; font-weight: bold;">is</span> <span style="color: #003366; font-weight: bold;">true</span> <span style="color: #000066; font-weight: bold;">for</span> all.
&nbsp;
<span style="color: #000066; font-weight: bold;">void</span> load <span style="color: #009900;">&#40;</span> hash <span style="color: #009900;">&#91;</span><span style="color: #339933;">,</span> title<span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span>
<span style="color: #339933;">@</span>param hash <span style="color: #339933;">&lt;</span>String<span style="color: #339933;">&gt;</span>  <span style="color: #339933;">-</span>  <span style="color: #003366; font-weight: bold;">New</span> hash to update
<span style="color: #339933;">@</span>param title <span style="color: #339933;">&lt;</span>String<span style="color: #339933;">&gt;</span> <span style="color: #339933;">-</span>  Title to set to the document</pre></div></div>

<p>If your application needs the hash state to complete the page you must set noHash and initReload to false. The iframe solution is not well tested since I don&#8217;t have plattform to test but I think it should function as the original one. I have only tested it on win7, IE8 running in mode IE7.  If you have a chance please test it!</p>
<p><strong>Issues</strong><br />
<lo>	</p>
<li>Chrome seems to break script-tag from serverfbml-tag (script-tag contains fbml-tag which is required in serverfbml-tag). This hapens when listening on popstate-event. Possible workaround is to initiate the history object when first used if there is fbml code.</li>
<p></lo></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">/*
 * jQuery history plugin
 * 
 * sample page: http://www.serpere.info/jquery-history-plugin/samples/
 *
 * Copyright (c) 2006-2009 Taku Sano (Mikage Sawatari)
 * Copyright (c) 2010 Takayuki Miwa
 * Licensed under the MIT License:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Modified by Lincoln Cooper to add Safari support 
 * and only call the callback once during initialization
 * for msie when no initial hash supplied.
 * 
 * Modified by Van Nhu Nguyen (2011);
 * redesign
 * use hash token #!
 * delay of iframe creation
 * support popstate and hashchange (html5)
 * always load page if dynamic content
 * shorten the hash if it is a full url
 * reload full page using the hash if enter the page with a hash
 * reload the page when user uses back-button 
 * and navigate to the &quot;entered&quot; page if this does not contain a hash 
 */</span>
&nbsp;
<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: #660066;">history</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> appState <span style="color: #339933;">=</span> undefined<span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> appCallback <span style="color: #339933;">=</span> undefined<span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> usePushState <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> dynamic <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> hashHandler <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> interval <span style="color: #339933;">=</span> <span style="color: #CC0000;">100</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> support <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> reloadIfInitHash <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> shortenHashPattern <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> RegExp<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;^&quot;</span> <span style="color: #339933;">+</span> document.<span style="color: #660066;">location</span>.<span style="color: #660066;">protocol</span>
				<span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\/</span><span style="color: #000099; font-weight: bold;">\/</span>&quot;</span> <span style="color: #339933;">+</span> document.<span style="color: #660066;">location</span>.<span style="color: #660066;">host</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;i&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> shortenHash <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> encodeHash <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		support.<span style="color: #660066;">needIframe</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>$.<span style="color: #660066;">browser</span>.<span style="color: #660066;">msie</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span>$.<span style="color: #660066;">browser</span>.<span style="color: #660066;">version</span> <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">8</span> <span style="color: #339933;">||</span> document.<span style="color: #660066;">documentMode</span> <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">8</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		support.<span style="color: #660066;">pushState</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">history</span> <span style="color: #339933;">&amp;&amp;</span> window.<span style="color: #660066;">history</span>.<span style="color: #660066;">pushState</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		support.<span style="color: #660066;">hashChange</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;onhashchange&quot;</span> <span style="color: #000066; font-weight: bold;">in</span> window<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> hashHandlers <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
		hashHandlers.<span style="color: #660066;">pushState</span> <span style="color: #339933;">=</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><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				appState <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>reloadIfInitHash<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #003366; font-weight: bold;">var</span> hash <span style="color: #339933;">=</span> getHash<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>hash<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
						window.<span style="color: #660066;">location</span> <span style="color: #339933;">=</span> hash<span style="color: #339933;">;</span>
						<span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span>
				$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;popstate&quot;</span><span style="color: #339933;">,</span> detectHashChange<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
			detect <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>
				appState <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				appCallback<span style="color: #009900;">&#40;</span>appState<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
			set <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>hash<span style="color: #339933;">,</span> title<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				window.<span style="color: #660066;">history</span>.<span style="color: #660066;">pushState</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span> title <span style="color: #339933;">?</span> title <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">,</span> hash<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
			get <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> window.<span style="color: #660066;">location</span>.<span style="color: #660066;">href</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
		hashHandlers.<span style="color: #660066;">hashChange</span> <span style="color: #339933;">=</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><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: #009900;">&#40;</span>appState <span style="color: #339933;">=</span> getHash<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</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>reloadIfInitHash<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
						window.<span style="color: #660066;">location</span> <span style="color: #339933;">=</span> appState<span style="color: #339933;">;</span>
						<span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
					appCallback<span style="color: #009900;">&#40;</span>appState<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>support.<span style="color: #660066;">hashChange</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;hashchange&quot;</span><span style="color: #339933;">,</span> detectHashChange<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
					setInterval<span style="color: #009900;">&#40;</span>detectHashChange<span style="color: #339933;">,</span> interval<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: #339933;">,</span>
			detect <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: #003366; font-weight: bold;">var</span> currentHash <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>currentHash<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>currentHash <span style="color: #339933;">!=</span> appState<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
						appState <span style="color: #339933;">=</span> currentHash<span style="color: #339933;">;</span>
						appCallback<span style="color: #009900;">&#40;</span>currentHash<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: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>appState<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					currentHash <span style="color: #339933;">=</span> cleanHash<span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">location</span>.<span style="color: #660066;">href</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					appState <span style="color: #339933;">=</span> currentHash<span style="color: #339933;">;</span>
					appCallback<span style="color: #009900;">&#40;</span>currentHash<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: #339933;">,</span>
			set <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>hash<span style="color: #339933;">,</span> title<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				setHash<span style="color: #009900;">&#40;</span>hash<span style="color: #339933;">,</span> window<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>title<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					document.<span style="color: #660066;">title</span> <span style="color: #339933;">=</span> title<span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
			get <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> getHash<span style="color: #009900;">&#40;</span>window<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: #339933;">;</span>
&nbsp;
		hashHandlers.<span style="color: #660066;">iframe</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003366; font-weight: bold;">var</span> id <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;__jQuery_history&quot;</span><span style="color: #339933;">;</span>
			<span style="color: #003366; font-weight: bold;">var</span> getIframeDocument <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #003366; font-weight: bold;">var</span> doc <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#&quot;</span> <span style="color: #339933;">+</span> id<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">contentWindow</span>.<span style="color: #660066;">document</span><span style="color: #339933;">;</span>
				<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					doc.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					doc.<span style="color: #000066;">close</span><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: #000066; font-weight: bold;">return</span> doc<span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
			<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><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #003366; font-weight: bold;">var</span> self <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
					<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>appState <span style="color: #339933;">=</span> getHash<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</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>reloadIfInitHash<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
							window.<span style="color: #660066;">location</span> <span style="color: #339933;">=</span> appState<span style="color: #339933;">;</span>
							<span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
						<span style="color: #009900;">&#125;</span>
						self <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
					<span style="color: #009966; font-style: italic;">/* delay call in case this method called before dom ready */</span>
					$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
						<span style="color: #003366; font-weight: bold;">var</span> html <span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt;iframe id=&quot;'</span>
							<span style="color: #339933;">+</span> id
							<span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot; style=&quot;display:none&quot; src=&quot;javascript:false;&quot; /&gt;'</span><span style="color: #339933;">;</span>
						$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;body&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">prepend</span><span style="color: #009900;">&#40;</span>html<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						setInterval<span style="color: #009900;">&#40;</span>detectHashChange<span style="color: #339933;">,</span> interval<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>appState<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
							appCallback<span style="color: #009900;">&#40;</span>appState<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
							self.<span style="color: #660066;">set</span><span style="color: #009900;">&#40;</span>appState<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;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
				detect <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: #003366; font-weight: bold;">var</span> currentHash <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #003366; font-weight: bold;">var</span> windowHash <span style="color: #339933;">=</span> getHash<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>currentHash <span style="color: #339933;">!=</span> appState<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
						appState <span style="color: #339933;">=</span> currentHash<span style="color: #339933;">;</span>
						setHash<span style="color: #009900;">&#40;</span>appState<span style="color: #339933;">,</span> window<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						appCallback<span style="color: #009900;">&#40;</span>appState<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>currentHash <span style="color: #339933;">!=</span> windowHash<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
						appState <span style="color: #339933;">=</span> windowHash<span style="color: #339933;">;</span>
						setHash<span style="color: #009900;">&#40;</span>appState<span style="color: #339933;">,</span> getIframeDocument<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						appCallback<span style="color: #009900;">&#40;</span>appState<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: #339933;">,</span>
				set <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>hash<span style="color: #339933;">,</span> title<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					setHash<span style="color: #009900;">&#40;</span>hash<span style="color: #339933;">,</span> getIframeDocument<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					setHash<span style="color: #009900;">&#40;</span>hash<span style="color: #339933;">,</span> window<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>title<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
						document.<span style="color: #660066;">title</span> <span style="color: #339933;">=</span> title<span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
				get <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> getHash<span style="color: #009900;">&#40;</span>getIframeDocument<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: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</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>
&nbsp;
		<span style="color: #003366; font-weight: bold;">var</span> setHash <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>hash<span style="color: #339933;">,</span> win<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			win.<span style="color: #660066;">location</span>.<span style="color: #660066;">hash</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;!&quot;</span>
					<span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>encodeHash <span style="color: #339933;">?</span> encodeURIComponent<span style="color: #009900;">&#40;</span>hash<span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> hash<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003366; font-weight: bold;">var</span> getHash <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>win<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003366; font-weight: bold;">var</span> hash <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>win.<span style="color: #660066;">location</span>.<span style="color: #660066;">hash</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/^#!/</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">return</span> $.<span style="color: #660066;">browser</span>.<span style="color: #660066;">mozilla</span> <span style="color: #339933;">?</span> hash
					<span style="color: #339933;">:</span> <span style="color: #009900;">&#40;</span>encodeHash <span style="color: #339933;">?</span> decodeURIComponent<span style="color: #009900;">&#40;</span>hash<span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> hash<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003366; font-weight: bold;">var</span> cleanHash <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>hash<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>shortenHash<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				hash <span style="color: #339933;">=</span> hash.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span>shortenHashPattern<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000066; font-weight: bold;">return</span> hash<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003366; font-weight: bold;">var</span> getHashHandler <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;">if</span> <span style="color: #009900;">&#40;</span>support.<span style="color: #660066;">needIframe</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000066; font-weight: bold;">return</span> hashHandlers.<span style="color: #660066;">iframe</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>support.<span style="color: #660066;">pushState</span> <span style="color: #339933;">&amp;&amp;</span> usePushState<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000066; font-weight: bold;">return</span> hashHandlers.<span style="color: #660066;">pushState</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000066; font-weight: bold;">return</span> hashHandlers.<span style="color: #660066;">hashChange</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003366; font-weight: bold;">var</span> detectHashChange <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>
			hashHandler.<span style="color: #660066;">detect</span><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: #339933;">;</span>
&nbsp;
		<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>callback<span style="color: #339933;">,</span> options<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>$.<span style="color: #660066;">isFunction</span><span style="color: #009900;">&#40;</span>callback<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000066; font-weight: bold;">throw</span> <span style="color: #003366; font-weight: bold;">new</span> Error<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;callback must be a function&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
				appCallback <span style="color: #339933;">=</span> callback<span style="color: #339933;">;</span>
				<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>options<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: #000066; font-weight: bold;">typeof</span> options.<span style="color: #660066;">noHash</span> <span style="color: #339933;">!=</span> <span style="color: #3366CC;">'undefined'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
						usePushState <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Boolean<span style="color: #009900;">&#40;</span>options.<span style="color: #660066;">noHash</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
					<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> options.<span style="color: #660066;">dynamic</span> <span style="color: #339933;">!=</span> <span style="color: #3366CC;">'undefined'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
						dynamic <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Boolean<span style="color: #009900;">&#40;</span>options.<span style="color: #660066;">dynamic</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
					<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> options.<span style="color: #660066;">initReload</span> <span style="color: #339933;">!=</span> <span style="color: #3366CC;">'undefined'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
						reloadIfInitHash <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Boolean<span style="color: #009900;">&#40;</span>options.<span style="color: #660066;">initReload</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
					<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> options.<span style="color: #660066;">shorten</span> <span style="color: #339933;">!=</span> <span style="color: #3366CC;">'undefined'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
						shortenHash <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Boolean<span style="color: #009900;">&#40;</span>options.<span style="color: #660066;">shorten</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span>
				hashHandler <span style="color: #339933;">=</span> getHashHandler<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				hashHandler.<span style="color: #660066;">init</span><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: #339933;">,</span>
			load <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>hash<span style="color: #339933;">,</span> title<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				hash <span style="color: #339933;">=</span> cleanHash<span style="color: #009900;">&#40;</span>hash<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>dynamic <span style="color: #339933;">||</span> hash <span style="color: #339933;">!=</span> appState<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					hashHandler.<span style="color: #660066;">set</span><span style="color: #009900;">&#40;</span>hash<span style="color: #339933;">,</span> title<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					appState <span style="color: #339933;">=</span> hash<span style="color: #339933;">;</span>
					appCallback<span style="color: #009900;">&#40;</span>hash<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: #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>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://howto.isgoodness.com/2011/02/jquery-history/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ReferenceError #1065: can not create property 0 on &#8230; (and #1069)</title>
		<link>http://howto.isgoodness.com/2010/02/referenceerror-1065-can-not-create-property-0-on-and-1069/</link>
		<comments>http://howto.isgoodness.com/2010/02/referenceerror-1065-can-not-create-property-0-on-and-1069/#comments</comments>
		<pubDate>Sun, 21 Feb 2010 13:20:44 +0000</pubDate>
		<dc:creator>Van Nhu</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[dynamic class]]></category>
		<category><![CDATA[reference error]]></category>
		<category><![CDATA[shuffle]]></category>

		<guid isPermaLink="false">http://howto.isgoodness.com/?p=422</guid>
		<description><![CDATA[Last week, I was trying to create a shuffle function on my array class which extends the native Array class. I got the ReferenceError when running the code bellow. The reason is that Array is a dynamic class and my is not. Since Array is dynamic, it will try to create new property when you [...]]]></description>
			<content:encoded><![CDATA[<p>Last week, I was trying to create a <a href="http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">shuffle </a>function on my array class which extends  the native Array class. I got the ReferenceError when running the code bellow. The reason is that Array is a dynamic class and my is not.  Since Array is dynamic, it will try to create new property when you try to assign some value to a nonexistent instance variable but MyArray prevents this. If you try this you will see that reference error #1065 is occurred when the array is constructed. If you remove the constructor you will get reference error #1069 instead and it hapens when you try to swap the elements in shuffle method (trying to access a nonexistent instance variable). So make sure that you declare dynamic if you extend a dynamic class or better if editor or compiler gives a warning if you forget &#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">&nbsp;
<span style="color: #9900cc; font-weight: bold;">package</span> vnmedia.common.lang
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> vnmedia.common.lang.math.Random;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> MyArray extends <span style="color: #004993;">Array</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> MyArray<span style="color: #000000;">&#40;</span>...<span style="color: #004993;">parameters</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">parameters</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> shuffle<span style="color: #000000;">&#40;</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> a<span style="color: #000000; font-weight: bold;">:*</span>, k<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span>, i<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span>, r<span style="color: #000000; font-weight: bold;">:</span>Random = <span style="color: #0033ff; font-weight: bold;">new</span> Random<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #0033ff; font-weight: bold;">for</span><span style="color: #000000;">&#40;</span>i = <span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">length</span>; i <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight:bold;">1</span>; i<span style="color: #000000; font-weight: bold;">--</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
				<span style="color: #009900;">// 0 &lt;= k &lt;= i - 1</span>
				k = r.nextInt<span style="color: #000000;">&#40;</span>i<span style="color: #000000;">&#41;</span>;
				a = <span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000;">&#91;</span>k<span style="color: #000000;">&#93;</span>;
				<span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000;">&#91;</span>k<span style="color: #000000;">&#93;</span> = <span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000;">&#91;</span>i<span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#93;</span>;
				<span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000;">&#91;</span>i<span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#93;</span> = a;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>However, I think the best way to provide a shuffle function for arrays is  to define a static ArrayUtil.shuffle as bellow</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> vnmedia.common.lang
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> vnmedia.common.lang.math.Random;
&nbsp;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> ArrayUtil
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> ArrayUtil<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> shuffle<span style="color: #000000;">&#40;</span>arr<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Array</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> a<span style="color: #000000; font-weight: bold;">:*</span>, k<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span>, i<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span>, r<span style="color: #000000; font-weight: bold;">:</span>Random = <span style="color: #0033ff; font-weight: bold;">new</span> Random<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #0033ff; font-weight: bold;">for</span><span style="color: #000000;">&#40;</span>i = arr.<span style="color: #004993;">length</span>; i <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight:bold;">1</span>; i<span style="color: #000000; font-weight: bold;">--</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
				k = r.nextInt<span style="color: #000000;">&#40;</span>i<span style="color: #000000;">&#41;</span>;
				a = arr<span style="color: #000000;">&#91;</span>k<span style="color: #000000;">&#93;</span>;
				arr<span style="color: #000000;">&#91;</span>k<span style="color: #000000;">&#93;</span> = arr<span style="color: #000000;">&#91;</span>i<span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#93;</span>;
				arr<span style="color: #000000;">&#91;</span>i<span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#93;</span> = a;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://howto.isgoodness.com/2010/02/referenceerror-1065-can-not-create-property-0-on-and-1069/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to get/kill process in ubuntu</title>
		<link>http://howto.isgoodness.com/2009/11/how-to-getkill-process-in-ubuntu/</link>
		<comments>http://howto.isgoodness.com/2009/11/how-to-getkill-process-in-ubuntu/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 15:19:10 +0000</pubDate>
		<dc:creator>Van Nhu</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[kill]]></category>
		<category><![CDATA[process]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://howto.isgoodness.com/?p=369</guid>
		<description><![CDATA[For example if process name is php, you can get a list of jobs by using the command bellow ps aux &#124; grep php Result root 7749 0.0 0.1 3236 796 pts/2 S+ 16:09 0:00 grep php root 19292 1.8 5.6 90624 28528 ? S 01:36 16:09 php test.php To kill a process you can [...]]]></description>
			<content:encoded><![CDATA[<p>For example if process name is php, you can get a list of jobs by using the command bellow</p>

<div class="wp_syntax"><div class="code"><pre class="cmd" style="font-family:monospace;">ps aux | grep php</pre></div></div>

<p>Result</p>

<div class="wp_syntax"><div class="code"><pre class="cmd" style="font-family:monospace;">root      7749  0.0  0.1   3236   796 pts/2    S+   16:09   0:00 grep php
root     19292  1.8  5.6  90624 28528 ?        S    01:36  16:09 php test.php</pre></div></div>

<p>To kill a process you can use kill with a specific pid, for instance 19292  above</p>

<div class="wp_syntax"><div class="code"><pre class="cmd" style="font-family:monospace;">kill 19292</pre></div></div>

<p>And kill all php process</p>

<div class="wp_syntax"><div class="code"><pre class="cmd" style="font-family:monospace;">killall -9 php</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://howto.isgoodness.com/2009/11/how-to-getkill-process-in-ubuntu/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Howto use vnkeys with TextField</title>
		<link>http://howto.isgoodness.com/2009/11/howto-use-vnkeys-with-textfield/</link>
		<comments>http://howto.isgoodness.com/2009/11/howto-use-vnkeys-with-textfield/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 21:00:06 +0000</pubDate>
		<dc:creator>Van Nhu</dc:creator>
				<category><![CDATA[vnkeys]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[key converter]]></category>
		<category><![CDATA[textfield]]></category>
		<category><![CDATA[typing vietnamese]]></category>

		<guid isPermaLink="false">http://howto.isgoodness.com/?p=310</guid>
		<description><![CDATA[vnkeys is originally designed to work with flash.text.TextField and you can feel it when typing. The replacement happens smoothly. It is easy to use and the code bellow will explain how to&#8230; package &#123; import flash.display.Sprite; import flash.text.TextField; import flash.text.TextFieldType; &#160; import org.vnmedia.vnkeys.KeyConverter; import org.vnmedia.vnkeys.mapping.VNIMap; // define swf dimension &#91;SWF&#40;width=160, height=60&#41;&#93; // this is an [...]]]></description>
			<content:encoded><![CDATA[<p>vnkeys is originally designed to work with flash.text.TextField and you can feel it when typing. The replacement happens smoothly. It is easy to use and the code bellow will explain how to&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">Sprite</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span>.<span style="color: #004993;">TextField</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span>.<span style="color: #004993;">TextFieldType</span>;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.vnmedia.vnkeys.KeyConverter;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.vnmedia.vnkeys.mapping.VNIMap;
	<span style="color: #009900;">// define swf dimension</span>
	<span style="color: #000000;">&#91;</span>SWF<span style="color: #000000;">&#40;</span><span style="color: #004993;">width</span>=<span style="color: #000000; font-weight:bold;">160</span>, <span style="color: #004993;">height</span>=<span style="color: #000000; font-weight:bold;">60</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
	<span style="color: #009900;">// this is an application class</span>
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> vnmedia_vnkeys extends <span style="color: #004993;">Sprite</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> vnmedia_vnkeys<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> textinput<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">TextField</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">TextField</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// give this text input a size</span>
			<span style="color: #009900;">// and positioning it</span>
			textinput.<span style="color: #004993;">width</span> = <span style="color: #000000; font-weight:bold;">150</span>;
			textinput.<span style="color: #004993;">height</span> = <span style="color: #000000; font-weight:bold;">50</span>;
			textinput.<span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">5</span>;
			textinput.<span style="color: #004993;">y</span> = <span style="color: #000000; font-weight:bold;">5</span>;
			<span style="color: #009900;">// use multiline, ie textarea</span>
			textinput.<span style="color: #004993;">multiline</span> = <span style="color: #0033ff; font-weight: bold;">true</span>;
			textinput.<span style="color: #004993;">type</span> = <span style="color: #004993;">TextFieldType</span>.<span style="color: #004993;">INPUT</span>;
			<span style="color: #009900;">// give it background white</span>
			<span style="color: #009900;">// so we can see what we are typing</span>
			textinput.<span style="color: #004993;">backgroundColor</span> = 0xFFFFFF;
			textinput.<span style="color: #004993;">background</span> = <span style="color: #0033ff; font-weight: bold;">true</span>;
			<span style="color: #009900;">// NOW create a converter</span>
			<span style="color: #009900;">// for this TextField instance</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> converter<span style="color: #000000; font-weight: bold;">:</span>KeyConverter =
				<span style="color: #0033ff; font-weight: bold;">new</span> KeyConverter<span style="color: #000000;">&#40;</span>textinput,VNIMap.NAME<span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// add this text input to application</span>
			<span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>textinput<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>The result:<br />
<object style="width: 160px; height: 60px;" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="160" height="60" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="scale" value="exactfit" /><param name="src" value="http://howto.isgoodness.com/wp-content/uploads/2009/11/vnmedia_vnkeys.swf" /><embed style="width: 160px; height: 60px;" type="application/x-shockwave-flash" width="160" height="60" src="http://howto.isgoodness.com/wp-content/uploads/2009/11/vnmedia_vnkeys.swf" scale="exactfit"></embed></object><br />
Type using <a href="http://howto.isgoodness.com/2009/10/how-to-type-vietnamese-with-vni-input-method-that-implemented-in-vnkeys/">VNI input method</a></p>
]]></content:encoded>
			<wfw:commentRss>http://howto.isgoodness.com/2009/11/howto-use-vnkeys-with-textfield/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to bootstrap, autoload modules and classes with Zend framework</title>
		<link>http://howto.isgoodness.com/2009/11/how-to-bootstrap-autoload-modules-and-classes-with-zend-framework/</link>
		<comments>http://howto.isgoodness.com/2009/11/how-to-bootstrap-autoload-modules-and-classes-with-zend-framework/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 21:24:34 +0000</pubDate>
		<dc:creator>Van Nhu</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[autoload]]></category>
		<category><![CDATA[bootstrap]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[modules]]></category>
		<category><![CDATA[zend framework]]></category>

		<guid isPermaLink="false">http://howto.isgoodness.com/?p=257</guid>
		<description><![CDATA[This post is for you that have read this quick start from Zend and our goal is to create a bootstrap like this one. We assume that you know how to create a project, layout, module, controller and action by using zf.bat, zf.sh or manually and further that you are able to create a helloworld [...]]]></description>
			<content:encoded><![CDATA[<p>This post is for you that have read this <a href="http://framework.zend.com/docs/quickstart" target="_blank">quick start</a> from Zend and <a href="#goal">our goal is to create a bootstrap like this one</a>. We assume that you know how to create a project, layout, module, controller and action by using zf.bat, zf.sh or manually and further that you are able to create a helloworld application with structure as bellow (I used zf.bat)</p>
<pre>
application
   configs
      application.ini
   layouts
      scripts
         layout.phtml
   modules
      default
         controllers
            ErrorController.php
            HelloworldController.php
            IndexController.php
         forms
            HelloWorld.php
         models
         views
            filters
            helpers
            scripts
              error
                 error.phtml
              helloworld
                 hello.phtml
              index
                 index.phtml
      second
         controllers
            HelloworldController.php
            IndexController.php
         forms
            HelloWorld.php
         models
         views
            filters
            helpers
            scripts
              helloworld
                 hello.phtml
              index
                 index.phtml
   Bootstrap.php
library
   Zend
   Foo
     Bar.php
public
   index.php
tests
</pre>
<p>We have now created two modules &#8220;default&#8221; and &#8220;second&#8221;. So far I can not create a project with default module inside folder modules so you need to move controllers, forms, models, views into default (create it first). However, the main purpose here is to show how to alter the Bootstrap that generated by zf.bat so that modules will be loaded and classes within modules, such as forms, models, can be autoloaded. In this example we will test for the form HelloWorld which is loaded in controller Helloworld. Here is the content of those files</p>
<p>default/controllers/HelloworldController.php</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> HelloworldController <span style="color: #000000; font-weight: bold;">extends</span> Zend_Controller_Action
<span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">/* Initialize action controller here */</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> indexAction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// action body</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> helloAction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$request</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
        <span style="color: #000088;">$form</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Default_Form_HelloWorld<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isPost</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        	<span style="color: #b1b100;">print</span> <span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getParam</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'hello'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$form</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>default/forms/HellowWorld.php</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> Default_Form_HelloWorld <span style="color: #000000; font-weight: bold;">extends</span> Zend_Form
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setMethod</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addElement</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'text'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'hello'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
            <span style="color: #0000ff;">'label'</span>      <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Hello default:'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'required'</span>   <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'filters'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'StringTrim'</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addElement</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'submit'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'submit'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
            <span style="color: #0000ff;">'ignore'</span>   <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'label'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Say'</span><span style="color: #339933;">,</span>
		<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>second/controllers/HelloworldController.php</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> Second_HelloworldController <span style="color: #000000; font-weight: bold;">extends</span> Zend_Controller_Action
<span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">/* Initialize action controller here */</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> indexAction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// action body</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> helloAction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$request</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$form</span>    <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Second_Form_HelloWorld<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isPost</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        	<span style="color: #b1b100;">print</span> <span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getParam</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'hello'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$form</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>second/forms/HelloWorld.php</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> Second_Form_HelloWorld <span style="color: #000000; font-weight: bold;">extends</span> Zend_Form
<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setMethod</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addElement</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'text'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'hello'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
            <span style="color: #0000ff;">'label'</span>      <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Hello second:'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'required'</span>   <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'filters'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'StringTrim'</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addElement</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'submit'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'submit'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
            <span style="color: #0000ff;">'ignore'</span>   <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'label'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Say'</span><span style="color: #339933;">,</span>
		<span style="color: #009900;">&#41;</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: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>default/views/scripts/helloworld/hello.phtml<br />
second/views/scripts/helloworld/hello.phtml</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAction</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">url</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: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>The first step we will try to do is to make sure that we can load the modules. We start to alter Bootstrap.php What we need to do is telling Front Controller where our modules are located</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Bootstrap <span style="color: #000000; font-weight: bold;">extends</span> Zend_Application_Bootstrap_Bootstrap
<span style="color: #009900;">&#123;</span>
	protected <span style="color: #000000; font-weight: bold;">function</span> _initDoctype<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	protected <span style="color: #000000; font-weight: bold;">function</span> _initApplication<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">bootstrap</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'FrontController'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$front</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getResource</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'FrontController'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$front</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">throwExceptions</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$front</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addModuleDirectory</span><span style="color: #009900;">&#40;</span>APPLICATION_PATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/modules'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Be aware that this can also be done in bootstrap file (public/index.php). One can do that by adding follow</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$frontController</span> <span style="color: #339933;">=</span> Zend_Controller_Front<span style="color: #339933;">::</span><span style="color: #004000;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$frontController</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addModuleDirectory</span><span style="color: #009900;">&#40;</span>APPLICATION_PATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/modules'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Or add this line in application.ini that is generated by zf.bat</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">resources<span style="color: #339933;">.</span>frontController<span style="color: #339933;">.</span>moduleDirectory <span style="color: #339933;">=</span> APPLICATION_PATH <span style="color: #0000ff;">&quot;/modules&quot;</span></pre></div></div>

<p>Now you should be able to navigate to http://yourserver/helloworld/hello or http://yourserver/second/helloworld/hello without any complain about &#8220;missing default module in front controller&#8221;. We got instead a fatal error which says that our form classes Default_Form_HelloWorld/Second_Form_HelloWorld is not found. The next is to enable autoloading of those form classes. To do that we start to edit Bootstrap.php again by adding init method _initAutoload() which will be called automatically</p>
<p><a name="goal"></a></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> Bootstrap <span style="color: #000000; font-weight: bold;">extends</span> Zend_Application_Bootstrap_Bootstrap
<span style="color: #009900;">&#123;</span>
&nbsp;
	protected <span style="color: #000000; font-weight: bold;">function</span> _initDoctype<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	protected <span style="color: #000000; font-weight: bold;">function</span> _initApplication<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">bootstrap</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'FrontController'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$front</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getResource</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'FrontController'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$front</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">throwExceptions</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$front</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addModuleDirectory</span><span style="color: #009900;">&#40;</span>APPLICATION_PATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/modules'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	protected <span style="color: #000000; font-weight: bold;">function</span> _initAutoload<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// BLOCK 1</span>
		<span style="color: #666666; font-style: italic;">// this is a fallback to autoload our own classes in library</span>
		<span style="color: #000088;">$autoLoader</span> <span style="color: #339933;">=</span> Zend_Loader_Autoloader<span style="color: #339933;">::</span><span style="color: #004000;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$autoLoader</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setFallbackAutoloader</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// BLOCK 2</span>
		<span style="color: #666666; font-style: italic;">// this is for loading forms classes in default module</span>
		<span style="color: #000088;">$autoloader</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Application_Module_Autoloader<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
        		<span style="color: #0000ff;">'namespace'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Default_'</span><span style="color: #339933;">,</span>
            		<span style="color: #0000ff;">'basePath'</span>  <span style="color: #339933;">=&gt;</span> APPLICATION_PATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/modules/default'</span><span style="color: #339933;">,</span>
        		<span style="color: #0000ff;">'resourceTypes'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                		<span style="color: #0000ff;">'forms'</span><span style="color: #339933;">=&gt;</span>array<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'path'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'/forms'</span><span style="color: #339933;">,</span>
					<span style="color: #0000ff;">'namespace'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'Form'</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// BLOCK 3</span>
		<span style="color: #666666; font-style: italic;">// this is for loading form classes in second module</span>
		<span style="color: #000088;">$autoloader</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Application_Module_Autoloader<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
        		<span style="color: #0000ff;">'namespace'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Second_'</span><span style="color: #339933;">,</span>
          		<span style="color: #0000ff;">'basePath'</span>  <span style="color: #339933;">=&gt;</span> APPLICATION_PATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/modules/second'</span><span style="color: #339933;">,</span>
        		<span style="color: #0000ff;">'resourceTypes'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                 		<span style="color: #0000ff;">'forms'</span><span style="color: #339933;">=&gt;</span>array<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'path'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'/forms'</span><span style="color: #339933;">,</span>
					<span style="color: #0000ff;">'namespace'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'Form'</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#41;</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: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><strong>BLOCK 1:</strong><br />
By default Zend_Loader_Autoloader will only load Zend classes. This code block tells Zend_Loader_Autoloader to include class files in 	arbitrary libraries. For instance, when you create a new &#8220;Bar&#8221;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$bar</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Foo_Bar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>It will try to include the file by looking in includepath/Foo/Bar.php and in our case it will include the file Foo/Bar.php</p>
<p><strong>BLOCK 2 &#038; 3:</strong><br />
Since Zend_Loader_Autoloader replaces _ in classname with / when loading the class file. But this will not work for classes in module folder. In these two code blocks we register the namespace and the corresponding path, ie if a class start with Second_ then it should look for the class file in application/modules/second/. When loading the form, in our case, it will add basePath and path, ie it will look for the class file in applicaton/modules/second/forms/.</p>
<p>Be aware that the namespace for your classes in forms and classes in library should distinct, for instance if I create a Foo class for module second in my library I should start with application name (helloworld) Helloworld_Second_Foo instead of Second_Foo which has the start namespace for the form, ie start-namespace conflict. I hope that this is the answer you are looking for &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://howto.isgoodness.com/2009/11/how-to-bootstrap-autoload-modules-and-classes-with-zend-framework/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to provide users options to switch on/off when using vnkeys</title>
		<link>http://howto.isgoodness.com/2009/10/how-to-provide-use-options-to-switch-onoff-when-using-vnkeys/</link>
		<comments>http://howto.isgoodness.com/2009/10/how-to-provide-use-options-to-switch-onoff-when-using-vnkeys/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 20:50:05 +0000</pubDate>
		<dc:creator>Van Nhu</dc:creator>
				<category><![CDATA[vnkeys]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[key converter]]></category>
		<category><![CDATA[mxml]]></category>
		<category><![CDATA[typing vietnamese]]></category>

		<guid isPermaLink="false">http://howto.isgoodness.com/?p=197</guid>
		<description><![CDATA[The goal of this post is to show how we can create a radio button group so users can switch on and off when using vnkeys as the swf above. To create TextArea and TextInput we use input components that follows vnkeys (see this how to for details). Bellow is our code example where we [...]]]></description>
			<content:encoded><![CDATA[<p><object style="width: 300px; height: 200px;" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="300" height="200" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://isgoodness.com/swf/vnkeys.swf" /><embed style="width: 300px; height: 200px;" type="application/x-shockwave-flash" width="300" height="200" src="http://isgoodness.com/swf/vnkeys.swf"></embed></object></p>
<p>The goal of this post is to show how we can create a radio button group so users can switch on and off when using vnkeys as the swf above. To create TextArea and TextInput we use input components that follows vnkeys (see <a href="http://howto.isgoodness.com/2009/10/how-to-use-vnkeys-with-flex/" target="_blank">this how to</a> for details). Bellow is our code example where we use flex RadioButtonGroup and RadioButton to create on/off options. We use Repeater to loop through options that we get from KeyConverter.getKeyMapOptions() This is done by calling init function initOptions() which fills element &#8220;options&#8221; with an array of available mapping types. On each option we attach function onMappingTypeChange as listener for onchange event so we can update mapping type on each KeyConverter instance.</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Application</span> xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> </span>
<span style="color: #000000;">	layout=<span style="color: #ff0000;">&quot;absolute&quot;</span></span>
<span style="color: #000000;">	 xmlns:flex=<span style="color: #ff0000;">&quot;org.vnmedia.flex.*&quot;</span> </span>
<span style="color: #000000;">	 creationComplete=<span style="color: #ff0000;">&quot;initOptions();&quot;</span><span style="color: #7400FF;">&gt;</span></span>
	<span style="color: #339933;">&lt;mx:Script&gt;</span>
<span style="color: #339933;">		&lt;![CDATA[</span>
<span style="color: #339933;">		import mx.controls.RadioButton;</span>
<span style="color: #339933;">		public function initOptions():void {</span>
<span style="color: #339933;">			options = area.getKeyConverter()</span>
<span style="color: #339933;">						.getKeyMapOptions();</span>
<span style="color: #339933;">		}</span>
<span style="color: #339933;">		public function onMappingTypeChange(e:Event):void {</span>
<span style="color: #339933;">			var radio:RadioButton = RadioButton(e.currentTarget);</span>
<span style="color: #339933;">			var item:Object = radio.getRepeaterItem();</span>
<span style="color: #339933;">			text.getKeyConverter().setMapType(item.data);</span>
<span style="color: #339933;">			area.getKeyConverter().setMapType(item.data);</span>
<span style="color: #339933;">		}</span>
<span style="color: #339933;">		]]&gt;</span>
<span style="color: #339933;">	&lt;/mx:Script&gt;</span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;flex:FlexTextArea</span> id=<span style="color: #ff0000;">&quot;area&quot;</span> vnkeyType=<span style="color: #ff0000;">&quot;VNI&quot;</span> </span>
<span style="color: #000000;">		height=<span style="color: #ff0000;">&quot;50&quot;</span> width=<span style="color: #ff0000;">&quot;220&quot;</span> x=<span style="color: #ff0000;">&quot;50&quot;</span> y=<span style="color: #ff0000;">&quot;50&quot;</span><span style="color: #7400FF;">&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;/flex:FlexTextArea</span><span style="color: #7400FF;">&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;flex:FlexTextInput</span> id=<span style="color: #ff0000;">&quot;text&quot;</span> y=<span style="color: #ff0000;">&quot;120&quot;</span></span>
<span style="color: #000000;">		 x=<span style="color: #ff0000;">&quot;50&quot;</span> width=<span style="color: #ff0000;">&quot;220&quot;</span><span style="color: #7400FF;">&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;/flex:FlexTextInput</span><span style="color: #7400FF;">&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Array</span> id=<span style="color: #ff0000;">&quot;options&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
   	<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:HBox</span> id=<span style="color: #ff0000;">&quot;hb&quot;</span> x=<span style="color: #ff0000;">&quot;50&quot;</span> y=<span style="color: #ff0000;">&quot;150&quot;</span><span style="color: #7400FF;">&gt;</span></span>	
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:RadioButtonGroup</span> id=<span style="color: #ff0000;">&quot;radioGroup&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Repeater</span> id=<span style="color: #ff0000;">&quot;radioRepeater&quot;</span></span>
<span style="color: #000000;">                dataProvider=<span style="color: #ff0000;">&quot;{options}&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:RadioButton</span> id=<span style="color: #ff0000;">&quot;radioButtons&quot;</span></span>
<span style="color: #000000;">                    label=<span style="color: #ff0000;">&quot;{radioRepeater.currentItem.label}&quot;</span></span>
<span style="color: #000000;">                    group=<span style="color: #ff0000;">&quot;{radioGroup}&quot;</span></span>
<span style="color: #000000;">                    change=<span style="color: #ff0000;">&quot;onMappingTypeChange(event);&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Repeater</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:HBox</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://howto.isgoodness.com/2009/10/how-to-provide-use-options-to-switch-onoff-when-using-vnkeys/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>how to use vnkeys with flex</title>
		<link>http://howto.isgoodness.com/2009/10/how-to-use-vnkeys-with-flex/</link>
		<comments>http://howto.isgoodness.com/2009/10/how-to-use-vnkeys-with-flex/#comments</comments>
		<pubDate>Sun, 25 Oct 2009 22:27:46 +0000</pubDate>
		<dc:creator>Van Nhu</dc:creator>
				<category><![CDATA[vnkeys]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[key converter]]></category>
		<category><![CDATA[mxml]]></category>
		<category><![CDATA[typing vietnamese]]></category>

		<guid isPermaLink="false">http://howto.isgoodness.com/?p=171</guid>
		<description><![CDATA[In the package org.vnmedia.flex we find two subclasses of Flex controls class. FlexTextInput is extending TextInput and FlexTextArea extending TextArea. Those two inherit all functionalities from their parent. We just added some more code handling the typing since TextInput and TextArea behaves unlike TextField. It is simple to use. You just need to declare namespace [...]]]></description>
			<content:encoded><![CDATA[<p>In the package org.vnmedia.flex we find two subclasses of Flex controls class. <a href="http://code.google.com/p/vnkeys/source/browse/branches/vni_and_flex/code/src/org/vnmedia/flex/FlexTextInput.as" target="_blank">FlexTextInput </a> is extending TextInput and <a href="http://code.google.com/p/vnkeys/source/browse/branches/vni_and_flex/code/src/org/vnmedia/flex/FlexTextArea.as" target="_blank">FlexTextArea </a> extending TextArea. Those two inherit all functionalities from their parent. We just added some more code handling the typing since TextInput and TextArea behaves unlike TextField. It is simple to use. You just need to declare namespace for org.vnmedia.flex, I call it &#8220;flex&#8221; in example bellow.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>Application xmlns<span style="color: #000000; font-weight: bold;">:</span>mx=<span style="color: #990000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> 
	xmlns<span style="color: #000000; font-weight: bold;">:</span>flex=<span style="color: #990000;">&quot;org.vnmedia.flex.*&quot;</span>
	layout=<span style="color: #990000;">&quot;absolute&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>flex<span style="color: #000000; font-weight: bold;">:</span>FlexTextArea id=<span style="color: #990000;">&quot;area&quot;</span> vnkeyType=<span style="color: #990000;">&quot;VNI&quot;</span> 
		<span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;50&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;220&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;50&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;50&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;/</span>flex<span style="color: #000000; font-weight: bold;">:</span>FlexTextArea<span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>flex<span style="color: #000000; font-weight: bold;">:</span>FlexTextInput id=<span style="color: #990000;">&quot;text&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;120&quot;</span>
		 <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;50&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;220&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;/</span>flex<span style="color: #000000; font-weight: bold;">:</span>FlexTextInput<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;/</span>mx<span style="color: #000000; font-weight: bold;">:</span>Application<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>You can type vietnamese using VNI input method (<a href="http://howto.isgoodness.com/2009/10/how-to-type-vietnamese-with-vni-input-method-that-implemented-in-vnkeys/" target="_blank">see</a>)<br />
<object style="width: 300px; height: 200px;" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="300" height="200" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://isgoodness.com/swf/flexvnkeys.swf" /><embed style="width: 300px; height: 200px;" type="application/x-shockwave-flash" width="300" height="200" src="http://isgoodness.com/swf/flexvnkeys.swf"></embed></object></p>
<p>vnkeys was designed to work well with Textfield. I guess that you feel that the replacement is a little bit annoying when using it with Flex TextInput and TextArea. <a href="http://isgoodness.com/swf/vnmedia_vnkeys.swf">Here is an example when using it with TextField</a>. It runs smoothly and you experience a bit faster. This is something that we will try to improve in the future version.</p>
]]></content:encoded>
			<wfw:commentRss>http://howto.isgoodness.com/2009/10/how-to-use-vnkeys-with-flex/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to type vietnamese with VNI input method that is implemented in vnkeys</title>
		<link>http://howto.isgoodness.com/2009/10/how-to-type-vietnamese-with-vni-input-method-that-implemented-in-vnkeys/</link>
		<comments>http://howto.isgoodness.com/2009/10/how-to-type-vietnamese-with-vni-input-method-that-implemented-in-vnkeys/#comments</comments>
		<pubDate>Sat, 24 Oct 2009 20:31:21 +0000</pubDate>
		<dc:creator>Van Nhu</dc:creator>
				<category><![CDATA[vnkeys]]></category>
		<category><![CDATA[key converter]]></category>
		<category><![CDATA[typing vietnamese]]></category>

		<guid isPermaLink="false">http://howto.isgoodness.com/?p=213</guid>
		<description><![CDATA[Bellow is a table on how to hit the keyboard (left hand side) to get the vietnamese letter (right hand side) VNI =&#62; Vietnamese a1 =&#62; á a2 =&#62; à a3 =&#62; ả a4 =&#62; ã a5 =&#62; ạ a6 =&#62; â o7 =&#62; ơ a8 =&#62; ă d9 =&#62; đ We do not implement [...]]]></description>
			<content:encoded><![CDATA[<p>Bellow is a table on how to hit the keyboard (left hand side) to get the vietnamese letter (right hand side)<br />
VNI =&gt; Vietnamese<br />
a1 =&gt; á<br />
a2 =&gt; à<br />
a3 =&gt; ả<br />
a4 =&gt; ã<br />
a5 =&gt; ạ<br />
a6 =&gt; â<br />
o7 =&gt; ơ<br />
a8 =&gt; ă<br />
d9 =&gt; đ</p>
<p>We do not implement all possible ways to type a vietnamese word. Example, there are many ways to type the word trường (school)</p>
<ul>
<li>truong72 → trường</li>
<li>truo72ng → trường</li>
<li>truo7ng2 → trường</li>
<li>tru7o72ng → trường</li>
<li>72truong → trường</li>
<li>t72ruong → trường</li>
<li>tr72uong → trường</li>
<li>&#8230;</li>
</ul>
<p>But in <a href="http://code.google.com/p/vnkeys/" target="_blank">vnkeys</a> you can only do that with the first four ways in this list. Another word, we implemented only the &#8220;natural ways&#8221; of typing. And natural means that you type in an order as you write on paper.</p>
]]></content:encoded>
			<wfw:commentRss>http://howto.isgoodness.com/2009/10/how-to-type-vietnamese-with-vni-input-method-that-implemented-in-vnkeys/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to implement singleton pattern in actionscript 3</title>
		<link>http://howto.isgoodness.com/2009/10/how-to-implement-singleton-pattern-in-actionscript-3/</link>
		<comments>http://howto.isgoodness.com/2009/10/how-to-implement-singleton-pattern-in-actionscript-3/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 20:02:30 +0000</pubDate>
		<dc:creator>Van Nhu</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[singleton]]></category>

		<guid isPermaLink="false">http://howto.isgoodness.com/?p=152</guid>
		<description><![CDATA[In actionscript 3 one can not use private scope for constructor and you need a workaround to implement simgleton pattern. Following is one way that I use package &#123; public class Singleton &#123; private static var instance:Singleton; private static var isAllowedInstance:Boolean; &#160; public function Singleton&#40;&#41; &#123; if &#40;!isAllowedInstance&#41; &#123; throw new Error&#40;&#34;Please use &#34; + [...]]]></description>
			<content:encoded><![CDATA[<p>In actionscript 3 one can not use private scope for constructor and you need a workaround to implement simgleton pattern. Following is one way that I use</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Singleton
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> static <span style="color: #6699cc; font-weight: bold;">var</span> instance<span style="color: #000000; font-weight: bold;">:</span>Singleton;
		<span style="color: #0033ff; font-weight: bold;">private</span> static <span style="color: #6699cc; font-weight: bold;">var</span> isAllowedInstance<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span>;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Singleton<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight: bold;">!</span>isAllowedInstance<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #0033ff; font-weight: bold;">throw</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Error</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Please use &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> 
						<span style="color: #990000;">&quot;Singleton.getInstance()&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> 
						<span style="color: #990000;">&quot;instead of new keyword&quot;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</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;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;init stuffs&quot;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> getInstance<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span>Singleton <span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">null</span> == instance<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				isAllowedInstance = <span style="color: #0033ff; font-weight: bold;">true</span>;
				instance = <span style="color: #0033ff; font-weight: bold;">new</span> Singleton<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
				isAllowedInstance = <span style="color: #0033ff; font-weight: bold;">false</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">return</span> instance;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> singsing<span style="color: #000000;">&#40;</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;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;singsing&quot;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>This will cause an error if someone uses the new keyword</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> singleton<span style="color: #000000; font-weight: bold;">:</span>Singleton = <span style="color: #0033ff; font-weight: bold;">new</span> Singleton<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</pre></div></div>

<p>It will work fine if you use it like this</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> singleton<span style="color: #000000; font-weight: bold;">:</span>Singleton = Singleton.getInstance<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://howto.isgoodness.com/2009/10/how-to-implement-singleton-pattern-in-actionscript-3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

