<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>masputih</title>
	
	<link>http://masputih.com</link>
	<description>Coder for Hire</description>
	<lastBuildDate>Tue, 10 Jan 2012 14:00:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/masputih" /><feedburner:info uri="masputih" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>AS3Isolib Game : Veer</title>
		<link>http://feedproxy.google.com/~r/masputih/~3/7K3_bz617nA/as3isolib-game-veer</link>
		<comments>http://masputih.com/2012/01/as3isolib-game-veer#comments</comments>
		<pubDate>Tue, 10 Jan 2012 14:00:17 +0000</pubDate>
		<dc:creator>Anggie Bratadinata</dc:creator>
				<category><![CDATA[AS3Isolib]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://masputih.com/?p=1039</guid>
		<description><![CDATA[I’ve been working on a facebook game called Veer (launched on January, 4th, 2012) for my client, Handson Entertainment . In this game, you play as a reporter, like Lois Lane, working for a news station, Veer. You begin your journey in a remote island called “Tuto Island” where you learn the basics of the [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><img src="http://masputih.com/wordpress/wp-content/uploads/2012/01/veer-110x300.jpg" alt="" title="veer" width="110" height="300" class="alignleft size-medium wp-image-1057" />I’ve been working on a facebook game called <a href="http://apps.facebook.com/playveer" title="Play veer on facebook" target="_blank">Veer</a> (launched on January, 4th, 2012) for my client, <a href="http://handson.com/" target="_blank">Handson Entertainment</a> . In this game, you play as a reporter, like Lois Lane, working for a news station, Veer. You begin your journey in a remote island called “Tuto Island” where you learn the basics of the game and then, as you level up, you will be taken to cities/places such as Paris, Monaco, Zanzibar, Beijing, etc. to hunt for interesting news.  Based on your locations and levels/experience, you will have different missions/tasks from finding a missing colleague, locating a run-away celebrity, and so on. Also, you get to visit famous landmarks like The Eiffel and Louvre Museum in Paris.</p>
<p><span id="more-1039"></span></p>
<p>The game was originally built as a hexagonal-tile game but my client decided to switch over to isometric in a later stage. Fortunately, I have enough experience with <a href="http://code.google.com/p/as3isolib/">as3isolib</a> so I managed to replace the hex engine while keeping most parts of the codebase relatively unchanged in just 3 sleepless days. </p>
<p>The project involved 3 flash developers, 4 rails developers, a couple of artists/animators, and a lot of QA guys. I developed the game framework, the rendering engine, and also tools for game designers/artists. Due to its simplicity and ease of use, I chose <a href="http://www.robotlegs.org">Robotlegs framework</a> as the foundation of the game framework to connect all different parts/modules and make them work together. </p>
<p>Here are screenshots of the game and the tools I built.</p>
<div id="attachment_1046" class="wp-caption alignleft" style="width: 300px">
	<a href="http://masputih.com/wordpress/wp-content/uploads/2012/01/veer_game.jpg"><img src="http://masputih.com/wordpress/wp-content/uploads/2012/01/veer_game-300x270.jpg" alt="" title="Veer Game" width="300" height="270" class="size-medium wp-image-1046" /></a>
	<p class="wp-caption-text">Veer Game</p>
</div>
<div id="attachment_1047" class="wp-caption alignleft" style="width: 300px">
	<a href="http://masputih.com/wordpress/wp-content/uploads/2012/01/veer_fullscreen.jpg"><img src="http://masputih.com/wordpress/wp-content/uploads/2012/01/veer_fullscreen-300x187.jpg" alt="" title="Fullscreen" width="300" height="187" class="size-medium wp-image-1047" /></a>
	<p class="wp-caption-text">Veer Fullscreen</p>
</div>
<div id="attachment_1050" class="wp-caption alignleft" style="width: 300px">
	<a href="http://masputih.com/wordpress/wp-content/uploads/2012/01/map_editor_1.jpg"><img src="http://masputih.com/wordpress/wp-content/uploads/2012/01/map_editor_1-300x156.jpg" alt="" title="Map Editor" width="300" height="156" class="size-medium wp-image-1050" /></a>
	<p class="wp-caption-text">Map Editor</p>
</div>
<div id="attachment_1052" class="wp-caption alignleft" style="width: 300px">
	<a href="http://masputih.com/wordpress/wp-content/uploads/2012/01/map_editor_3.jpg"><img src="http://masputih.com/wordpress/wp-content/uploads/2012/01/map_editor_3-300x156.jpg" alt="" title="Map Editor" width="300" height="156" class="size-medium wp-image-1052" /></a>
	<p class="wp-caption-text">Map Editor</p>
</div>
<div id="attachment_1051" class="wp-caption alignleft" style="width: 300px">
	<a href="http://masputih.com/wordpress/wp-content/uploads/2012/01/map_editor_2.jpg"><img src="http://masputih.com/wordpress/wp-content/uploads/2012/01/map_editor_2-300x161.jpg" alt="" title="Map Editor" width="300" height="161" class="size-medium wp-image-1051" /></a>
	<p class="wp-caption-text">Map Editor</p>
</div>
<div id="attachment_1049" class="wp-caption alignleft" style="width: 300px">
	<a href="http://masputih.com/wordpress/wp-content/uploads/2012/01/asset_editor.jpg"><img src="http://masputih.com/wordpress/wp-content/uploads/2012/01/asset_editor-300x212.jpg" alt="" title="Asset Editor" width="300" height="212" class="size-medium wp-image-1049" /></a>
	<p class="wp-caption-text">Asset Editor</p>
</div>
<div id="attachment_1053" class="wp-caption alignleft" style="width: 300px">
	<a href="http://masputih.com/wordpress/wp-content/uploads/2012/01/swf2spritesheet.jpg"><img src="http://masputih.com/wordpress/wp-content/uploads/2012/01/swf2spritesheet-300x228.jpg" alt="" title="Spritesheet generator" width="300" height="228" class="size-medium wp-image-1053" /></a>
	<p class="wp-caption-text">Spritesheet generator</p>
</div>
<p>The game is still a work in progress and some things are not well polished but it’s playable. So <a href="http://apps.facebook.com/playveer" target="_blank">play the game</a> <img src='http://masputih.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>

<p><a href="http://feedads.g.doubleclick.net/~a/gflv4iEOEvxcYGL2PjL7xXp8YDM/0/da"><img src="http://feedads.g.doubleclick.net/~a/gflv4iEOEvxcYGL2PjL7xXp8YDM/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/gflv4iEOEvxcYGL2PjL7xXp8YDM/1/da"><img src="http://feedads.g.doubleclick.net/~a/gflv4iEOEvxcYGL2PjL7xXp8YDM/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/masputih/~4/7K3_bz617nA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://masputih.com/2012/01/as3isolib-game-veer/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://masputih.com/2012/01/as3isolib-game-veer</feedburner:origLink></item>
		<item>
		<title>Class Generator Flash Extension</title>
		<link>http://feedproxy.google.com/~r/masputih/~3/sy4WyPHa9c8/class-generator-flash-extension</link>
		<comments>http://masputih.com/2011/12/class-generator-flash-extension#comments</comments>
		<pubDate>Fri, 02 Dec 2011 06:00:44 +0000</pubDate>
		<dc:creator>Anggie Bratadinata</dc:creator>
				<category><![CDATA[Extension]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[extension]]></category>

		<guid isPermaLink="false">http://masputih.com/?p=983</guid>
		<description><![CDATA[Here’s an extension that allows you to quickly export your symbols for actionscript and create their bound-classes. Features Manual &#38; automatic modes. In manual mode, the extension will only process the selected symbols in the library panel. In automatic mode, it will process all symbols of the types you choose. You can select a folder [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a href="http://masputih.com/wordpress/wp-content/uploads/2011/12/class_generator.jpg"><img src="http://masputih.com/wordpress/wp-content/uploads/2011/12/class_generator-300x226.jpg" alt="" title="class_generator" width="300" height="226" class="alignleft size-medium wp-image-1007" /></a> </p>
<p>Here’s an extension that allows you to quickly export your symbols for actionscript and create their bound-classes. </p>
<h3>Features</h3>
<ol>
<li>Manual &amp; automatic modes. In manual mode, the extension will only process the selected symbols in the library panel. In automatic mode, it will process <em>all</em> symbols of the types you choose.
</li>
<li>You can select a folder (root) where the .as files will be created. If you don’t select a root folder, the files will be created in the same folder as your .fla.</li>
<li>Custom base classes and packages. <em>Note that this extension will not create the base class for you.</em></li>
</ol>
<p><span id="more-983"></span></p>
<h3>Demo</h3>
<span style="text-align:center; display: block;"><a href="http://masputih.com/2011/12/class-generator-flash-extension"><img src="http://img.youtube.com/vi/GTvKFK_nMr8/2.jpg" alt="" /></a></span>
<h3>Download</h3>
<p>Download the extension here <a href="http://masputih.com/wordpress/wp-content/plugins/download-monitor/download.php?id=class_generator.zip" title="Downloaded 30 times">→ Class Generator </a>. Extract the zip and install the mxp.</p>
<h3>Warning</h3>
<p>If you want to use this extension when working on an ongoing project. Make sure you backup your .as files before generating classes as this extension might overwrite them.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/K-bhumOV0KnE49fWpslSJ_YJl3s/0/da"><img src="http://feedads.g.doubleclick.net/~a/K-bhumOV0KnE49fWpslSJ_YJl3s/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/K-bhumOV0KnE49fWpslSJ_YJl3s/1/da"><img src="http://feedads.g.doubleclick.net/~a/K-bhumOV0KnE49fWpslSJ_YJl3s/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/masputih/~4/sy4WyPHa9c8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://masputih.com/2011/12/class-generator-flash-extension/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://masputih.com/2011/12/class-generator-flash-extension</feedburner:origLink></item>
		<item>
		<title>How to Enable ANT view on FlashBuilder 4.5</title>
		<link>http://feedproxy.google.com/~r/masputih/~3/zE1X_7b4RlY/how-to-enable-ant-view-on-flashbuilder-4-5</link>
		<comments>http://masputih.com/2011/11/how-to-enable-ant-view-on-flashbuilder-4-5#comments</comments>
		<pubDate>Sun, 20 Nov 2011 05:54:37 +0000</pubDate>
		<dc:creator>Anggie Bratadinata</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://masputih.com/?p=964</guid>
		<description><![CDATA[For those who can’t find Ant View on FB 4.5. Step 1 : Go to File-&#62;New Project to open the Project Wizard. Step 2 : Check Show All Wizards. Step 3 : Expand Java from the list. Select Java Project from Existing Ant Buildfile then click Next. You’ll be prompted with a dialog to enable [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>For those who can’t find Ant View on FB 4.5. </p>
<p><a href="http://masputih.com/wordpress/wp-content/uploads/2011/11/project_wiz.jpg"><img src="http://masputih.com/wordpress/wp-content/uploads/2011/11/project_wiz-300x285.jpg" alt="" title="project_wiz" width="300" height="285" class="alignleft size-medium wp-image-965" /></a></p>
<p>Step 1 : Go to <em>File-&gt;New Project</em> to open the <em>Project Wizard</em>.</p>
<p>Step 2 : Check <em>Show All Wizards</em>.</p>
<p><span id="more-964"></span></p>
<p style="clear:left"/>
<a href="http://masputih.com/wordpress/wp-content/uploads/2011/11/enable_activities.jpg"><img src="http://masputih.com/wordpress/wp-content/uploads/2011/11/enable_activities-300x285.jpg" alt="" title="enable_activities" width="300" height="285" class="alignleft size-medium wp-image-968" /></a><br />
Step 3 : Expand <em>Java</em> from the list. Select <em>Java Project from Existing Ant Buildfile</em> then click <em>Next</em>. You’ll be prompted with a dialog to enable <em>Ant Development</em>. </p>
<p>Step 4 : Check <em>Always enable activities and don’t ask me again</em> then click <em>OK</em>.</p>
<p>Step 5 : Back on the Project Wizard. Click <em>Cancel</em>.</p>
<p style="clear:left"/>
<a href="http://masputih.com/wordpress/wp-content/uploads/2011/11/ant_view.jpg"><img src="http://masputih.com/wordpress/wp-content/uploads/2011/11/ant_view-213x300.jpg" alt="" title="ant_view" width="213" height="300" class="alignleft size-medium wp-image-969" /></a><br />
Now you should see ANT when you go to <em>Window -&gt; Show View -&gt; Other</em>. </p>

<p><a href="http://feedads.g.doubleclick.net/~a/65m6GkOo_nILbMnKMGrMJPfEmqA/0/da"><img src="http://feedads.g.doubleclick.net/~a/65m6GkOo_nILbMnKMGrMJPfEmqA/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/65m6GkOo_nILbMnKMGrMJPfEmqA/1/da"><img src="http://feedads.g.doubleclick.net/~a/65m6GkOo_nILbMnKMGrMJPfEmqA/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/masputih/~4/zE1X_7b4RlY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://masputih.com/2011/11/how-to-enable-ant-view-on-flashbuilder-4-5/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://masputih.com/2011/11/how-to-enable-ant-view-on-flashbuilder-4-5</feedburner:origLink></item>
		<item>
		<title>Isometric Helper Flash Extension</title>
		<link>http://feedproxy.google.com/~r/masputih/~3/BK41uLTUuHU/isometric-helper-flash-extension</link>
		<comments>http://masputih.com/2011/11/isometric-helper-flash-extension#comments</comments>
		<pubDate>Fri, 18 Nov 2011 20:02:03 +0000</pubDate>
		<dc:creator>Anggie Bratadinata</dc:creator>
				<category><![CDATA[Extension]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[extension]]></category>

		<guid isPermaLink="false">http://masputih.com/?p=934</guid>
		<description><![CDATA[I’ve been working on isometric games for quite a while. Although i work with a team of artists who are capable of making beautiful assets, I often need to create them myself for quick prototypes. Creating isometric assets is time consuming. I know prototypes don’t have to be pretty but still, I don’t want to [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><img src="http://masputih.com/wordpress/wp-content/uploads/2011/11/iso_helper.jpg" alt="" title="iso_helper panel" width="201" height="361" class="alignleft size-full wp-image-939" /></p>
<p>I’ve been working on isometric games for quite a while. Although i work with a team of artists who are capable of making beautiful assets, I often need to create them myself for quick prototypes. Creating isometric assets is time consuming. I know prototypes don’t have to be pretty but still, I don’t want to show crap. </p>
<p>I had been looking for a flash extension that could help me quickly create assets but I found none that i liked so I decided to make one myself. This is the first flash extension that i ever made. One thing I learned from making this extension : JSFL is a pain in the ass.</p>
<p><span id="more-934"></span></p>
<h3>What does it do?</h3>
<p>Just a few things that I need:</p>
<ul>
<li>Create an isometric grid and put it in a guide layer. <em>Note: if you’re using as3isolib, cell height in the panel = IsoGrid.cellSize</em></li>
<li>Transform (skew, rotate, scale) selected objects on the stage so that they can be used for constructing isometric objects</li>
</ul>
<h3>How to use</h3>
<span style="text-align:center; display: block;"><a href="http://masputih.com/2011/11/isometric-helper-flash-extension"><img src="http://img.youtube.com/vi/ZZw3Q_VYa_E/2.jpg" alt="" /></a></span>
<h3>Download</h3>
<p>Download the extension here <a href="http://masputih.com/wordpress/wp-content/plugins/download-monitor/download.php?id=isometric_helper.zip" title="Downloaded 58 times">→ isometric_helper</a> . Extract the zip and install the .mxp.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/uS9zEbRdaMDhj6Oh__alvcmOXYs/0/da"><img src="http://feedads.g.doubleclick.net/~a/uS9zEbRdaMDhj6Oh__alvcmOXYs/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/uS9zEbRdaMDhj6Oh__alvcmOXYs/1/da"><img src="http://feedads.g.doubleclick.net/~a/uS9zEbRdaMDhj6Oh__alvcmOXYs/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/masputih/~4/BK41uLTUuHU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://masputih.com/2011/11/isometric-helper-flash-extension/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://masputih.com/2011/11/isometric-helper-flash-extension</feedburner:origLink></item>
		<item>
		<title>IRS, US tax Confusion: Offshore freelancers don’t need ITIN</title>
		<link>http://feedproxy.google.com/~r/masputih/~3/QaVQNhVRlIs/irs-us-tax-confusion-offshore-freelancers-dont-need-itin</link>
		<comments>http://masputih.com/2011/08/irs-us-tax-confusion-offshore-freelancers-dont-need-itin#comments</comments>
		<pubDate>Thu, 04 Aug 2011 19:45:33 +0000</pubDate>
		<dc:creator>Anggie Bratadinata</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://masputih.com/?p=916</guid>
		<description><![CDATA[I had been trying to get my individual tax id from IRS since January because the company i’m working for told me that I needed it in order to get full payments, otherwise they had to withhold 30% of my monthly fees according to IRS regulation. People said it would be a long process, and [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>I had been trying to get my individual tax id from IRS since January because the company i’m working for told me that I needed it in order to get full payments, otherwise they had to withhold 30% of my monthly fees according to IRS regulation. People said it would be a long process, and they are right!</p>
<p>After months exchanging emails with a tax consultant, getting the required papers from the company &amp; from <a href="http://www.ssa.gov/">SSA</a> office in the US embassy in Manila, sending my passport to a friend in the US to get a notarized copy, etc., I received a letter from IRS saying that my application was rejected because my passport copy was not properly notarized. I was puzzled so I asked my manager in the US to call IRS to get a clarification. After about an hour of getting transferred from one IRS agent to another (it would cost me a serious amount of $ if I called them myself), he finally got to talk to someone who could answer our inquiry. The answer is … I don’t need/qualify for ITIN because I perform my work in Indonesia, not in the US. The agent referred to <a href="http://www.irs.gov/publications/p515/ar02.html#en_US_2011_publink1000224882">this IRS publication</a>, specifically the part that reads:</p>
<blockquote><p><strong>Services performed outside the United States.</strong> Compensation paid to a nonresident alien (other than a resident of Puerto Rico, discussed later) for services performed outside the United States is not considered wages and is not subject to withholding.</p></blockquote>
<p>So if you’re working remotely for a US company and the company asks for your ITIN, show them the publication. </p>

<p><a href="http://feedads.g.doubleclick.net/~a/unntVZBoWpSlFqSkoogYHqGa1aM/0/da"><img src="http://feedads.g.doubleclick.net/~a/unntVZBoWpSlFqSkoogYHqGa1aM/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/unntVZBoWpSlFqSkoogYHqGa1aM/1/da"><img src="http://feedads.g.doubleclick.net/~a/unntVZBoWpSlFqSkoogYHqGa1aM/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/masputih/~4/QaVQNhVRlIs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://masputih.com/2011/08/irs-us-tax-confusion-offshore-freelancers-dont-need-itin/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://masputih.com/2011/08/irs-us-tax-confusion-offshore-freelancers-dont-need-itin</feedburner:origLink></item>
		<item>
		<title>as3isolib on playbook, first look</title>
		<link>http://feedproxy.google.com/~r/masputih/~3/YZFvhAqhCbY/as3isolib-on-playbook-first-look</link>
		<comments>http://masputih.com/2011/07/as3isolib-on-playbook-first-look#comments</comments>
		<pubDate>Wed, 13 Jul 2011 09:19:23 +0000</pubDate>
		<dc:creator>Anggie Bratadinata</dc:creator>
				<category><![CDATA[AS3Isolib]]></category>

		<guid isPermaLink="false">http://masputih.com/?p=907</guid>
		<description><![CDATA[I got a playbook (for free … yay!) from a RIM dev partner a few days ago and I couldn’t wait to convert an as3isolib demo i wrote a while ago and see it run on that nice gadget. So here it is.]]></description>
			<content:encoded><![CDATA[<p></p><p>I got a playbook (for free … yay!) from a RIM dev partner a few days ago and I couldn’t wait to convert an <a href="http://code.google.com/p/as3isolib/">as3isolib</a> demo i wrote a while ago and see it run on that nice gadget.</p>
<p>So here it is.</p>
<span style="text-align:center; display: block;"><a href="http://masputih.com/2011/07/as3isolib-on-playbook-first-look"><img src="http://img.youtube.com/vi/9vsfWqhIwAc/2.jpg" alt="" /></a></span>

<p><a href="http://feedads.g.doubleclick.net/~a/qcBqX3IUvoYnZaWL8ubHryYI91I/0/da"><img src="http://feedads.g.doubleclick.net/~a/qcBqX3IUvoYnZaWL8ubHryYI91I/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/qcBqX3IUvoYnZaWL8ubHryYI91I/1/da"><img src="http://feedads.g.doubleclick.net/~a/qcBqX3IUvoYnZaWL8ubHryYI91I/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/masputih/~4/YZFvhAqhCbY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://masputih.com/2011/07/as3isolib-on-playbook-first-look/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://masputih.com/2011/07/as3isolib-on-playbook-first-look</feedburner:origLink></item>
		<item>
		<title>Making Rotatable IsoGroup</title>
		<link>http://feedproxy.google.com/~r/masputih/~3/ohMCubhBK2g/making-rotatable-isogroup</link>
		<comments>http://masputih.com/2011/02/making-rotatable-isogroup#comments</comments>
		<pubDate>Fri, 04 Feb 2011 17:53:00 +0000</pubDate>
		<dc:creator>Anggie Bratadinata</dc:creator>
				<category><![CDATA[AS3Isolib]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[as3isolib]]></category>

		<guid isPermaLink="false">http://masputih.com/?p=817</guid>
		<description><![CDATA[In this article, I will show you how to make a rotatable IsoGroup in As3Isolib. Well, I don’t actually rotate the group but instead, I reposition the group’s children so that the group appears to be rotated. If you’re new to As3Isolib, you can learn a bit about the basics here. If you know the [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>In this article, I will show you how to make a rotatable <code>IsoGroup</code> in <a href="http://as3isolib.wordpress.com/">As3Isolib</a>. Well, I don’t actually rotate the group but instead, I reposition the group’s children so that the group <em>appears</em> to be rotated. <img src='http://masputih.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>If you’re new to As3Isolib, you can learn a bit about the basics here. If you know the library already, you might want to skip step 1.</p>
<p>Basic steps:</p>
<ul>
<li>Subclass the <code>IsoGroup</code></li>
<li>Map the group’s children’s positions to a 2d array</li>
<li>Add rotation logic</li>
<li>Rotate the array</li>
<li>Use the array to reposition the children</li>
<li>Render</li>
</ul>
<p>What I need:</p>
<ol>
<li><a href="https://github.com/jaybaird/as3ds">as3ds Array2 class</a></li>
<li>an algorithm to rotate a 2d rectangular array. Just google it. It’s everywhere <img src='http://masputih.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  </li>
</ol>
<p><span id="more-817"></span></p>
<h3>Step 1 — Set up my world</h3>
<p>I’m going to make a world ( <code>IsoView</code> ) that contains 2 scenes. One at the bottom to contain an instance of <code>IsoGrid</code> and on top of that, another scene to contain isometric objects. So I’ll start a document class with just a few methods as follows: </p>
<pre class="brush:as3">
package
{
	import as3isolib.display.IsoView;
	import as3isolib.display.scene.IsoGrid;
	import as3isolib.display.scene.IsoScene;
	import flash.display.Sprite;
	import flash.events.Event;

	public class Main extends Sprite
	{

		private var _world:IsoView;
		private var _grid:IsoGrid;
		private var _groupScene:IsoScene;

		public function Main():void
		{
			if (stage)
				init();
			else
				addEventListener(Event.ADDED_TO_STAGE, init);
		}

		private function init(e:Event = null):void
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			createWorld();

		}

		private function createWorld():void
		{
			_world = new IsoView();
			_world.setSize(400, 400);
			addChild(_world);

			///////// GRID
			_grid = new IsoGrid();
			_grid.setGridSize(10, 10);
			_grid.cellSize = 20;

			var gridScene:IsoScene = new IsoScene();
			gridScene.addChild(_grid);

			_world.addScene(gridScene);

			///////// GROUP SCENE
			_groupScene = new IsoScene();
			_world.addScene(_groupScene);

			_world.addEventListener(Event.ENTER_FRAME, render);
		}

		private function render(e:Event):void
		{
			_world.render(true);

		}
	}
}
</pre>
<p><div id="attachment_828" class="wp-caption alignleft" style="width: 240px">
	<img src="http://masputih.com/wordpress/wp-content/uploads/2011/02/empty_world.jpg" alt="" title="Empty World" width="240" height="240" class="size-full wp-image-828" />
	<p class="wp-caption-text">Empty World</p>
</div><br />
<strong>Line 33 — 35</strong> : Creates an instance of <code>IsoView</code>. </p>
<p><strong>Line 38 — 45</strong>: Creates an <code>IsoGrid</code> and an <code>IsoScene</code> to contain it. And then adds the scene to the <code>IsoView</code>. </p>
<p><strong>Line 48 — 49</strong>: Creates a scene to contain the <code>IsoGroup</code> and adds it to the <code>IsoView</code>. </p>
<p>The last line sets <code>ENTER_FRAME</code> listener to render the world.</p>
<p>If I compile the class now, I’ll get something like the picture on the left.</p>
<h3>Step 2 — Write a custom IsoGroup</h3>
<p>Now I’m going to extend IsoGroup and add some cool stuff. First, some basic stuff just to set things up. </p>
<pre class="brush:as3">
package
{
	import as3isolib.display.IsoGroup;
	import as3isolib.display.scene.IsoGrid;

	public class Group extends IsoGroup
	{
		protected var _grid:IsoGrid;

		public function Group(grid:IsoGrid, descriptor:Object = null)
		{
			super(descriptor);
			_grid = grid;
		}
	}
}
</pre>
<p>Then I add a method through which I can send a 2d array to the <code>Group</code> and let it build a bunch of <code>IsoBox</code>.</p>
<pre class="brush:as3">
public function setMap(map:Array):void
{

	if (children.length > 0)
	{
		removeAllChildren();
	}

	//make NxN array that represents the group's layout
	//this is the array we'll rotate
	var w:Number = Math.max(map[0].length, map.length);
	_layout = new Array2(w,w);
	_layout.fill(0);

	for (var row:int = 0; row < map.length; row++)
	{
		var r:Array = map[row];

		for (var col:int = 0; col < r.length; col++)
		{
			if (map[row][col] != 0)
			{
				var box:IsoBox = new IsoBox();
				box.fills = [new SolidColorFill(0x00FFFF, 1), new SolidColorFill(0x8080C0, 1), new SolidColorFill(0xFF8040, 1)];
				box.setSize(_grid.cellSize, _grid.cellSize, 40);
				box.moveTo(_grid.cellSize * col, _grid.cellSize * row, 0);
				box.name = map[row][col];
				addChild(box);

				_layout.set(col, row, box);
			}
		}
	}

}
</pre>
<p><strong>Line 4 — 7</strong>: Removes all previous children in the group if there’s any. </p>
<p><strong>Line 11 —  13</strong>: make a square <code>Array2</code> based on the number of columns or rows in the passed array — whichever the largest to make sure that when I move its elements, they will not fall out of bounds. I use the array as a reference to the positions of the group’s children (<code>IsoBox</code>) and I call it <code>_layout</code>.</p>
<p><strong>Line 15 — 33</strong>: Loop through the <code>Array2</code> and create <code>IsoBox</code> instances. Note that I’ll use <code>0</code> in the array to mark places that I want to be empty. So in the loop, I check if an element is a <code>0</code> or not. If it is not a <code>0</code>, I create an <code>IsoBox</code> there. And store a reference to it in the <code>_layout</code> array.</p>
<p>Back to the <code>Main</code> class. I add a new method to create my group and I also define the group’s map.</p>
<pre class="brush:as3">
private var _map:Array = [
	[0, 'A', 'B', 'C'],
	['D', 'E', 'F', 'G']
];

private function init(e:Event = null):void
{
	removeEventListener(Event.ADDED_TO_STAGE, init);
	createWorld();
	createGroup();
}

private function createGroup():void
{
	_group = new Group(_grid);
	_group.setMap(_map);
	_group.moveTo(60, 60, 0);
	_groupScene.addChild(_group);

}
</pre>
<p>So far I get this when I compile the codes :<br />
<div id="attachment_866" class="wp-caption aligncenter" style="width: 238px">
	<img src="http://masputih.com/wordpress/wp-content/uploads/2011/02/basic_group1.jpg" alt="" title="Basic Group" width="238" height="215" class="size-full wp-image-866" />
	<p class="wp-caption-text">Basic Group</p>
</div></p>
<p>Pretty, eh? <img src='http://masputih.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<h3>Step 3 — Make the group rotatable</h3>
<p>Now that I have the basic group in place it’s time to make it rotatable. So I add a new method <code>rotate()</code> that takes a boolean flag to indicates if the rotation is clockwise (<code>true</code>) or counter-clockwise (<code>false</code>).</p>
<pre class="brush:as3">
public function rotate(clockWise:Boolean = true):void
{

	//make a new NxN array for the new layout ( after rotation )
	var w:Number =_layout.width;
	var newLayout:Array2 = new Array2(w, w);
	newLayout.fill(0);

	for (var r:int = 0; r < w; r++)
	{
		for (var c:int = 0; c < w; c++)
		{
			//found this array-rotation algo somewhere on the web
			var c0:int = (clockWise == true) ? w - 1 - r : r;
			var r0:int = (clockWise == true) ? c : w - 1 - c;

			newLayout.set(c0, r0, _layout.get(c, r));
		}
	}

	_layout = newLayout;
	updateChildren();

}

protected function updateChildren():void
{
	for (var r:int = 0; r < _layout.height; r++)
	{
		for (var c:int = 0; c < _layout.width; c++)
		{
			if (_layout.get(c, r) is IsoBox)
			{
				_layout.get(c, r).moveTo(c * _grid.cellSize, r * _grid.cellSize, 0);
			}
		}

	}
}
</pre>
<p><strong>Line 5 — 7</strong>: Makes an empty array for the new layout</p>
<p><strong>Line 13 –14</strong>: Using the algorithm, I figure out where each box should end up</p>
<p><strong>Line 15</strong>: Set the box to a corresponding position in the new layout</p>
<p><strong>Line 21</strong>: replace the old layout with the new one</p>
<p><strong>Line 26 — 39</strong>: move the boxes to their new positions using the new layout as a reference</p>
<p>Back to the Main class again, I add some buttons to set the group’s rotation and I have something like this (click the black buttons): </p>

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="swfobj_0" width="400" height="400">
      <param name="movie" value="http://masputih.com/wordpress/wp-content/uploads/2011/02/Rotatableisogroup.swf" />
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="http://masputih.com/wordpress/wp-content/uploads/2011/02/Rotatableisogroup.swf" width="400" height="400">
      <!--<![endif]-->
        
      <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>

<p>So that’s basically all the steps to make a rotatable IsoGroup. Pretty simple, right?</p>
<h3>Extra — A group that can be rotated over a pivot</h3>
<p>As an extra, here’s a <code>Group</code> subclass that allows you to rotate it around a selected box (pivot). What different in this new class from the <code>Group</code> is the way it handles the rotation. Look at <code>rotate()</code> and <code>updateChildren()</code>. Basically, what this class does is move itself so that the pivot box stays at the same position as it was before rotation.</p>
<p>Here’s the demo. Click a box to select a pivot. Click it again to deselect. When there’s no box selected, the group can rotate just like the one above.</p>

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="swfobj_1" width="400" height="400">
      <param name="movie" value="http://masputih.com/wordpress/wp-content/uploads/2011/02/RotatableisogroupWPivot.swf" />
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="http://masputih.com/wordpress/wp-content/uploads/2011/02/RotatableisogroupWPivot.swf" width="400" height="400">
      <!--<![endif]-->
        
      <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>

<p>And here’s the class:</p>
<pre class="brush:as3">
package
{
	import as3isolib.display.primitive.IsoBox;
	import as3isolib.display.scene.IsoGrid;
	import as3isolib.graphics.SolidColorFill;
	import eDpLib.events.ProxyEvent;
	import flash.events.MouseEvent;

	/**
	 * ...
	 * @author Anggie Bratadinata | www.masputih.com
	 */
	public class GroupWithPivot extends Group
	{

		public var selectedBox:IsoBox;

		private var _selectedBox_oldX:Number;
		private var _selectedBox_oldY:Number;

		public function GroupWithPivot(grid:IsoGrid, descriptor:Object = null)
		{
			super(grid, descriptor);

		}

		override public function setMap(map:Array):void
		{
			super.setMap(map);

			for each (var isoBox:IsoBox in children)
			{
				isoBox.addEventListener(MouseEvent.CLICK, onBoxClick);
			}
		}

		private function onBoxClick(e:ProxyEvent):void
		{
			var newBox:IsoBox = e.target as IsoBox;

			if (selectedBox != null)
			{
				//reset color
				selectedBox.fills = [new SolidColorFill(0x00FFFF, 1), new SolidColorFill(0x8080C0, 1), new SolidColorFill(0xFF8040, 1)];
			}
			if (newBox != selectedBox)
			{
				//set new color
				newBox.fills = [new SolidColorFill(0x804040, 1), new SolidColorFill(0x400000, 1), new SolidColorFill(0x804040, 1)];
				selectedBox = newBox;
			}
			else
			{
				selectedBox = null;
			}

		}

		override public function rotate(clockWise:Boolean = true):void
		{
			if (selectedBox != null)
			{
				_selectedBox_oldX = selectedBox.x;
				_selectedBox_oldY = selectedBox.y;
			}

			super.rotate(clockWise);

		}

		override protected function updateChildren():void
		{
			super.updateChildren();

			if (selectedBox != null)
			{
				var dx:int = selectedBox.x - _selectedBox_oldX;
				var dy:int = selectedBox.y - _selectedBox_oldY;
				moveTo(x - dx, y - dy, 0);

			}
		}

	}

}
</pre>
<h3>Download</h3>
<p>Here’s a zip containing all of those classes : <a href="http://masputih.com/wordpress/wp-content/plugins/download-monitor/download.php?id=rotatable-isogroup.zip" title="Downloaded 261 times">→ Rotatable Group Project</a></p>

<p><a href="http://feedads.g.doubleclick.net/~a/cnS5UMhmMI_gkOqedkcVaVNLuq4/0/da"><img src="http://feedads.g.doubleclick.net/~a/cnS5UMhmMI_gkOqedkcVaVNLuq4/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/cnS5UMhmMI_gkOqedkcVaVNLuq4/1/da"><img src="http://feedads.g.doubleclick.net/~a/cnS5UMhmMI_gkOqedkcVaVNLuq4/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/masputih/~4/ohMCubhBK2g" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://masputih.com/2011/02/making-rotatable-isogroup/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://masputih.com/2011/02/making-rotatable-isogroup</feedburner:origLink></item>
		<item>
		<title>SpriteSheet class for AS3Isolib</title>
		<link>http://feedproxy.google.com/~r/masputih/~3/497ubkPxNDc/spritesheet-class-for-as3isolib</link>
		<comments>http://masputih.com/2011/01/spritesheet-class-for-as3isolib#comments</comments>
		<pubDate>Sun, 23 Jan 2011 10:41:31 +0000</pubDate>
		<dc:creator>Anggie Bratadinata</dc:creator>
				<category><![CDATA[AS3Isolib]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[as3isolib]]></category>

		<guid isPermaLink="false">http://masputih.com/?p=772</guid>
		<description><![CDATA[One of the requirements of my latest as3isolib project was to have “realistic” looks for all objects. The only way to achieve this is use bitmap assets so I paid a friend who’s really good at making animated 3d models to create animated assets for me and render them as PNG sprite sheets. Another thing [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>One of the requirements of my latest as3isolib project was to have “realistic” looks for all objects. The only way to achieve this is use bitmap assets so I paid a friend who’s really good at making animated 3d models to create animated assets for me and render them as PNG sprite sheets. Another thing I had to do was <a href="http://en.wikipedia.org/wiki/Bit_blit">blit</a> the sheets but there’s no built-in bitmap blitter class in as3isolib that I could use so I wrote the <code>SpriteSheet</code> class below. </p>
<pre class="brush:as3">
package iso
{
	import de.polygonal.ds.Array2;
	import iso.Directions;
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	import flash.utils.getTimer;

	/**
	 * Bitmap-blitter. The source must be a bitmap or sprite with 8 rows representing 8 directions.
	 * Each row contains an animation cycle where column 0 is for idle state.
	 *
	 * @author Anggie Bratadinata
	 */
	public class SpriteSheet extends Sprite
	{
		//rendering interval
		public static const RENDER_INTERVAL:Number = 64;

		//bitmap frames
		protected var _bitmapArray:Array2;
		//sheet source
		protected var _source:DisplayObject;
		//frame size
		protected var _frameWidth:Number;
		protected var _frameHeight:Number;
		//the rendered bitmap
		protected var _frameBitmap:Bitmap;
		protected var _frameRect:Rectangle;

		//current facing direction
		protected var _direction:String;
		//current frame row
		protected var _currentRow:Array;
		protected var _currentColNum:Number;
		//render timer
		protected var _oldTime:Number = 0;
		protected var _renderInterval:Number;

		//is the south-facing sequence on the first row (true) or not (false)?
		protected var _southFirst:Boolean;

		//the visual state
		protected var _isIdle:Boolean;

		//if true, a new bitmap will be generated
		protected var _isDirty:Boolean;

		public function SpriteSheet()
		{

		}

		/**
		 * Build the sprite sheet. The source must contain 8 rows of animation frames arranged in clockwise order.
		 * The first row can be the south face or the south west. A tool like SpriteForge renders tilesheets
		 * with the south-facing sequence on the first row.
		 *
		 * Acceptable row arrangements : S,SW,W,NW,N,NE,E,SE or SW,W,NW,N,NE,E,SE,S
		 *
		 * @param	source			The source Display object.
		 * @param	frameWidth		animation frame width
		 * @param	frameHeight		animation frame height
		 * @param	renderInterval	delay between renders. This defines the animation blitting speed in milliseconds
		 * @param	southFirst		the south-facing sequence is on the first row (true) or the last (false).
		 *
		 */
		public function build(source:DisplayObject, frameWidth:Number, frameHeight:Number, renderInterval:Number = SpriteSheet.RENDER_INTERVAL, southFirst:Boolean = true):void
		{

			_source = source;
			_frameWidth = frameWidth;
			_frameHeight = frameHeight;
			_renderInterval = renderInterval;
			_southFirst = southFirst;

			var sourceBd:BitmapData = new BitmapData(source.width, source.height, true, 0x00000000);
			sourceBd.draw(source, null, null, null, null, true);

			var numCols:Number = Math.floor(source.width / frameWidth);
			var numRows:Number = Math.floor(source.height / frameHeight);

			_frameRect = new Rectangle(0, 0, frameWidth, frameHeight);

			_bitmapArray = new Array2(numCols, numRows);

			for (var i:int = 0; i < numRows; i++)
			{
				for (var j:int = 0; j < numCols; j++)
				{
					var bd:BitmapData = new BitmapData(frameWidth, frameHeight, true, 0x000000);
					_frameRect.x = j * frameWidth;
					_frameRect.y = i * frameHeight;

					bd.copyPixels(sourceBd, _frameRect, new Point(0, 0));

					_bitmapArray.set(j, i, bd);

				}

			}

			_frameRect.x = 0;
			_frameRect.y = 0;

			//if the south faces is on the last row, move it to the first
			if (!_southFirst)
			{
				_bitmapArray.shiftDown();
			}

			setDirection(Directions.S);
			idle();

			_oldTime = getTimer();
			addEventListener(Event.ENTER_FRAME, onEnterFrame);

		}

		/**
		 * Set the state to idle
		 */
		public function idle():void
		{

			_isIdle = true;
			_isDirty = true;
		};

		/**
		 * Set the state to walk/animated
		 *
		 */
		public function action():void
		{
			_isIdle = false;
			_isDirty = true;
		};

		protected function onEnterFrame(e:Event = null):void
		{

			var elapsed:Number = getTimer() - _oldTime;

			if (elapsed >= _renderInterval &#038;& _isDirty)
			{
				render();
				_oldTime = getTimer();
			}

		}

		protected function render():void
		{
			if (_frameBitmap == null)
			{
				_frameBitmap = new Bitmap(new BitmapData(_frameWidth, _frameHeight, true, 0x00000000));
				addChild(_frameBitmap);
			}

			_frameBitmap.bitmapData.lock();

			if (_isIdle)
			{
				_currentColNum = 0;
				_frameBitmap.bitmapData.copyPixels(_currentRow[_currentColNum], _frameRect, new Point(0, 0), null, null, false);
				//trace(this + "render idle");
				_isDirty = false;
			}
			else
			{

				if (_currentColNum < _currentRow.length-1)
				{
					try {
						_frameBitmap.bitmapData.copyPixels(_currentRow[_currentColNum], _frameRect, new Point(0, 0), null, null, false);
					}catch (error:Error) {
						//trace("ERROR RENDERING : " + _currentColNum);
						return;
					}
					_currentColNum++;
				}
				else
				{
					_currentColNum = 1;
				}

				_isDirty = true;
			}

			_frameBitmap.bitmapData.unlock();
		}

		/**
		 * Set the active direction and make _currentRow point to a specific row in _bitmapArray
		 * @param	direction
		 */
		public function setDirection(direction:String):void
		{
			//trace(this +"set direction : " +direction);
			_direction = direction;
			var rowNum:Number;
			switch (direction)
			{
				case Directions.S:
					rowNum = 0;
					break;
				case Directions.SW:
					rowNum = 1;
					break;
				case Directions.W:
					rowNum = 2;
					break;
				case Directions.NW:
					rowNum = 3;
					break;
				case Directions.N:
					rowNum = 4;
					break;
				case Directions.NE:
					rowNum = 5;
					break;
				case Directions.E:
					rowNum = 6;
					break;
				case Directions.SE:
					rowNum = 7;
					break;
				default:
					rowNum = 0;
			}
			//trace(this + "setDirection, row " + rowNum);
			_currentRow = _bitmapArray.getRow(rowNum);

			_isDirty = true;
			render();

		}

		/**
		 * Get currently rendered frame
		 *
		 * @return Bitmap
		 */
		public function getFrameBitmap():Bitmap
		{
			return _frameBitmap;
		}

		/**
		 * Get current direction
		 * @return
		 */
		public function getDirection():String
		{
			return _direction;
		};

	}

}
</pre>
<p>Next, I’ll explain how to create your sheets.</p>
<p><span id="more-772"></span></p>
<h2>Creating the sheets</h2>
<p>Rules:</p>
<ul>
<li>The sheet must have <em>8 rows</em> , one for each direction, arranged in clockwise order</li>
<li>Either the first or last row must contain sequence for animations used when the object is facing south. The acceptable row order is <em>S-SW-W-NW-N-NE-E-SE</em> or <em>SW-W-NW-N-NE-E-SE-S</em></li>
<li>The first <em>column</em> is used for “idle” state</li>
</ul>
<p>Example:</p>
<div id="attachment_785" class="wp-caption aligncenter" style="width: 176px">
	<a href="http://masputih.com/wordpress/wp-content/uploads/2011/01/f0.png"><img src="http://masputih.com/wordpress/wp-content/uploads/2011/01/f0-176x300.png" alt="" title="Sample Sprite Sheet" width="176" height="300" class="size-medium wp-image-785" /></a>
	<p class="wp-caption-text">Sample Sprite Sheet</p>
</div>
<p>3d artists usually know how to render 3d animated models as sprite sheets but if you don’t have anyone to do that for you and you, like myself, don’t know how to use 3d editors, you can use one of these tools below to make png sprite sheets out of 3d models. None of them is free but they are all worth buying: </p>
<ul>
<li><a href="http://www.d-grafix.com/">SpriteForge</a> ( supports multiple formats : md2, b3d, x, etc). This is what I use. The site seems down when I’m writing this article, though.</li>
<li><a href="http://www.envygames.com/content/index.php/tools/turn-3d-models-into-2d-animated-sprites">SpriteWorks</a> (collada &amp; .dts only) </li>
<li><a href="http://www.fragmosoft.com/">FragMotion</a> (supports multiple formats ). Last time I tried it, it could only render one row at a time so I had to use Fireworks to combine and arrange the output PNGs as one big sheet.</li>
</ul>
<p>Next, you have to find out the dimension of the frame in your png sheet which is easy; just divide the width of the png by the number of columns to get the frame width and divide the height of the png by the number of rows to get the frame height. If you use one of the tools in the list above, you don’t have to calculate the frame dimensions yourself because you have to enter their values somewhere before you hit render button.</p>
<h2>Test your sheet</h2>
<p>Now you can test your sheet. The SpriteSheet class has 2 states : “idle” and “action”. If you set it to idle by calling <code>idle()</code> function, it will render a frame from the first column. If you set it to action by calling <code>action()</code>, it will blit all frames in a row, depends on the direction you set, starting from the second column until you set it to idle again. Since the <code>SpriteSheet</code> class doesn’t depend on any as3isolib class and it extends <code>flash.display.Sprite</code>, you can test it easily. Here’s a sample tester:</p>
<pre class="brush:as3">
package
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import iso.Directions;
	import iso.SpriteSheet;

	/**
	 * ...
	 * @author Anggie Bratadinata | www.masputih.com
	 */
	public class Tester extends Sprite
	{
		[Embed(source='f0.png')]
		public const SHEET:Class;

		public const SHEET_FRAME_WIDTH:Number = 48;
		public const SHEET_FRAME_HEIGHT:Number = 92;

		private var _ss:SpriteSheet;

		public function Tester()
		{
			addEventListener(Event.ADDED_TO_STAGE, init);
		}

		private function init(e:Event):void
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);

			createUI();
			createSpriteSheet();

		}

		private function createSpriteSheet():void
		{

			_ss = new SpriteSheet();
			_ss.build(new SHEET(), SHEET_FRAME_WIDTH, SHEET_FRAME_HEIGHT);
			_ss.x = _ss.y = 100
			addChild(_ss);

		}

		private function changeDirection(e:Event):void
		{
			var s:Sprite = Sprite(e.target);
			_ss.setDirection(s.name);
		}

		private function changeState(e:Event):void
		{
			var s:Sprite = Sprite(e.target);

			if (s.name == "idle")
			{
				_ss.idle();
			}
			else if (s.name == "action")
			{
				_ss.action();
			}
		}

		private function createUI():void
		{
			addChild(createButton("action", 10, 10, changeState));
			addChild(createButton("idle", 80, 10, changeState));

			addChild(createButton(Directions.S, 10, 40, changeDirection, 0x400080));
			addChild(createButton(Directions.SW, 80, 40, changeDirection, 0x400080));
			addChild(createButton(Directions.W, 150, 40, changeDirection, 0x400080));
			addChild(createButton(Directions.NW, 230, 40, changeDirection, 0x400080));
			addChild(createButton(Directions.N, 10, 70, changeDirection, 0x400080));
			addChild(createButton(Directions.NE, 80, 70, changeDirection, 0x400080));
			addChild(createButton(Directions.E, 150, 70, changeDirection, 0x400080));
			addChild(createButton(Directions.SE, 230, 70, changeDirection, 0x400080));

		}

		private function createButton(labelText:String, x:Number, y:Number, clickListener:Function, bgColor:uint = 0, labelColor:uint = 0xFFFFFF, width:Number = 60):Sprite
		{

			var label:TextField = new TextField();
			label.textColor = labelColor;
			label.autoSize = TextFieldAutoSize.LEFT;
			label.text = labelText;

			var s:Sprite = new Sprite();
			s.addChild(label);
			s.name = labelText;

			with (s)
			{
				graphics.beginFill(bgColor);
				graphics.drawRect(0, 0, 60, 20);
				graphics.endFill();
			}
			s.x = x;
			s.y = y;
			s.mouseChildren = false;
			s.addEventListener(MouseEvent.CLICK, clickListener);
			return s;
		}

	}

}
</pre>
<div class="flash_box">
<p>Click on the black/blue buttons</p>

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="swfobj_2" width="300" height="300">
      <param name="movie" value="http://masputih.com/wordpress/wp-content/uploads/2011/01/SpritesheetTester.swf" />
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="http://masputih.com/wordpress/wp-content/uploads/2011/01/SpritesheetTester.swf" width="300" height="300">
      <!--<![endif]-->
        
      <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>
</div>
<h2>Attaching the SpriteSheet to IsoSprite</h2>
<p>Using the SpriteSheet to skin an IsoSprite is easy. An extra step you must do is offset the <code>SpriteSheet</code> so its frames can be placed correctly in IsoSprite.container. See the samples below.</p>
<div id="attachment_791" class="wp-caption aligncenter" style="width: 500px">
	<img src="http://masputih.com/wordpress/wp-content/uploads/2011/01/sheet_offsets.jpg" alt="" title="Offsets" width="500" height="193" class="size-full wp-image-791" />
	<p class="wp-caption-text">Without &amp; With offsets</p>
</div>
<pre class="brush:as3">
package
{
	import as3isolib.display.IsoSprite;
	import as3isolib.display.IsoView;
	import as3isolib.display.scene.IsoGrid;
	import as3isolib.display.scene.IsoScene;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import iso.*;

	public class Demo extends Sprite
	{

		[Embed(source='f0.png')]
		public const SHEET:Class;

		public const SHEET_FRAME_WIDTH:Number = 48;
		public const SHEET_FRAME_HEIGHT:Number = 92;

		private var _view:IsoView;
		private var _ss:SpriteSheet;

		public function Demo():void
		{
			addEventListener(Event.ADDED_TO_STAGE, init);
		}

		private function init(e:Event):void
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);

			createSpriteSheet();
			createIso();
			createUI();

		}

		private function createSpriteSheet():void
		{
			_ss = new SpriteSheet();
			_ss.build(new SHEET(), SHEET_FRAME_WIDTH, SHEET_FRAME_HEIGHT);
			//offset the sprite sheet
			_ss.x = -13;
			_ss.y = -65;

		}

		private function createIso():void
		{
			////////// GRID
			var grid:IsoGrid = new IsoGrid();
			grid.setGridSize(4, 4);
			grid.cellSize = 20;

			var gscene:IsoScene = new IsoScene();
			gscene.addChild(grid);

			////////// ISO SPRITE
			var isoSprite:IsoSprite = new IsoSprite();
			isoSprite.setSize(20, 20, 80);
			isoSprite.moveTo(-10, 0, 0);
			//attach the spritesheet to isosprite
			isoSprite.sprites = [_ss];

			var scene:IsoScene = new IsoScene();
			scene.addChild(isoSprite);

			////////// ISO VIEW
			_view = new IsoView();
			_view.y = 100;
			_view.setSize(stage.stageWidth, 200);
			_view.addScene(gscene);
			_view.addScene(scene);
			_view.addEventListener(Event.ENTER_FRAME, render);
			addChild(_view);

		}

		private function render(e:Event):void
		{
			_view.render(true);
		}

		private function changeDirection(e:Event):void
		{
			var s:Sprite = Sprite(e.target);
			_ss.setDirection(s.name);
		}

		private function changeState(e:Event):void
		{
			var s:Sprite = Sprite(e.target);

			if (s.name == "idle")
			{
				_ss.idle();
			}
			else if (s.name == "action")
			{
				_ss.action();
			}
		}

		private function createUI():void
		{
			addChild(createButton("action", 10, 10, changeState));
			addChild(createButton("idle", 80, 10, changeState));

			addChild(createButton(Directions.S, 10, 40, changeDirection, 0x400080));
			addChild(createButton(Directions.SW, 80, 40, changeDirection, 0x400080));
			addChild(createButton(Directions.W, 150, 40, changeDirection, 0x400080));
			addChild(createButton(Directions.NW, 230, 40, changeDirection, 0x400080));
			addChild(createButton(Directions.N, 10, 70, changeDirection, 0x400080));
			addChild(createButton(Directions.NE, 80, 70, changeDirection, 0x400080));
			addChild(createButton(Directions.E, 150, 70, changeDirection, 0x400080));
			addChild(createButton(Directions.SE, 230, 70, changeDirection, 0x400080));

		}

		private function createButton(labelText:String, x:Number, y:Number, clickListener:Function, bgColor:uint = 0, labelColor:uint = 0xFFFFFF, width:Number = 60):Sprite
		{

			var label:TextField = new TextField();
			label.textColor = labelColor;
			label.autoSize = TextFieldAutoSize.LEFT;
			label.text = labelText;

			var s:Sprite = new Sprite();
			s.addChild(label);
			s.name = labelText;

			with (s)
			{
				graphics.beginFill(bgColor);
				graphics.drawRect(0, 0, 60, 20);
				graphics.endFill();
			}
			s.x = x;
			s.y = y;
			s.mouseChildren = false;
			s.addEventListener(MouseEvent.CLICK, clickListener);
			return s;
		}
	}

}
</pre>
<div class="flash_box">
<p>Click on the black/blue buttons</p>

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="swfobj_3" width="300" height="300">
      <param name="movie" value="http://masputih.com/wordpress/wp-content/uploads/2011/01/SpritesheetDemo.swf" />
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="http://masputih.com/wordpress/wp-content/uploads/2011/01/SpritesheetDemo.swf" width="300" height="300">
      <!--<![endif]-->
        
      <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>
</div>
<p>Here’s the zip containing all of those stuff above:<br />
<a href="http://masputih.com/wordpress/wp-content/plugins/download-monitor/download.php?id=as3isolib_spritesheet.zip" title="Downloaded 777 times">→ Spritesheet Demo</a></p>
<p>That’s it. Enjoy the class and let me know if you have problems.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/y4Dxl_gmS8SXSn5UdcRxW6cqf9Q/0/da"><img src="http://feedads.g.doubleclick.net/~a/y4Dxl_gmS8SXSn5UdcRxW6cqf9Q/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/y4Dxl_gmS8SXSn5UdcRxW6cqf9Q/1/da"><img src="http://feedads.g.doubleclick.net/~a/y4Dxl_gmS8SXSn5UdcRxW6cqf9Q/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/masputih/~4/497ubkPxNDc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://masputih.com/2011/01/spritesheet-class-for-as3isolib/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://masputih.com/2011/01/spritesheet-class-for-as3isolib</feedburner:origLink></item>
		<item>
		<title>Helping client find a web host</title>
		<link>http://feedproxy.google.com/~r/masputih/~3/RM85hDv4aP0/helping-client-find-a-web-host</link>
		<comments>http://masputih.com/2010/10/helping-client-find-a-web-host#comments</comments>
		<pubDate>Sun, 17 Oct 2010 04:47:12 +0000</pubDate>
		<dc:creator>Anggie Bratadinata</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://masputih.com/?p=756</guid>
		<description><![CDATA[So you have done a flash website for your client. You put all the necessary files on your server for demoing your hard work to them. They like it very much and think that you’re the best coder out there. Now they want your help to set up a server for the website too because [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>So you have done a flash website for your client. You put all the necessary files on your server for demoing your hard work to them. They like it very much and think that you’re the best coder out there. </p>
<p>Now they want your help to set up a server for the website too because it is the first website they ever had and they don’t have a clue on how and where to host their shiny, brand new website. They are not really tech-savvy so telling them to google for web hosts won’t do any good for them. They might even get confused by thousands of web hosting sites Google gives them. Of course, you can go to authoritative forums like webhostingtalk.com to help them find a good host but it’s going to cost you some time. Oh and the client think that you can do this for free because you’re a rock star coder and you can do it in just a few minutes.</p>
<p><a href="http://masputih.com/wordpress/wp-content/uploads/2010/10/webhostingsearch.jpg"><img src="http://masputih.com/wordpress/wp-content/uploads/2010/10/webhostingsearch.jpg" alt="" title="webhostingsearch" width="300" height="246" class="alignleft size-full wp-image-759" /></a></p>
<p>I had been in the same situation many times. The best places for me and my clients to look for solid webhosts and compare them easily are webhosting review sites. A review site that I just recently found is Web Hosting Search. This review site provides quick links to find hosts along with their ratings by the operating systems. So if your client wants Mac, you can just go to <a href="http://www.webhostingsearch.com/mac-web-hosting.php">Mac Web Hosting</a> or Windows Web Hosting if they want Windows. </p>
<p>Webhostingsearch is more than just a review site. It also contains lots of useful informations for people who don’t know anything about web hosting or the web in general. So your client will not only be able to choose a web host that fits their site’s requirements and their budget but they can also learn a few things about the web like how to set up a website, what web hosting is all about, etc. So whether it is a Mac Web Hosting or a <a href="http://www.webhostingsearch.com/windows-web-hosting.php">Windows Web Hosting</a>, they have it!</p>
<p>So, by directing your client to Webhostingsearch, you not only save your time and theirs but also help them to learn more about the web. </p>
<p>Good luck!</p>

<p><a href="http://feedads.g.doubleclick.net/~a/k70wLE4xztLR_PCHwYipi8aSumg/0/da"><img src="http://feedads.g.doubleclick.net/~a/k70wLE4xztLR_PCHwYipi8aSumg/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/k70wLE4xztLR_PCHwYipi8aSumg/1/da"><img src="http://feedads.g.doubleclick.net/~a/k70wLE4xztLR_PCHwYipi8aSumg/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/masputih/~4/RM85hDv4aP0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://masputih.com/2010/10/helping-client-find-a-web-host/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://masputih.com/2010/10/helping-client-find-a-web-host</feedburner:origLink></item>
		<item>
		<title>Creating Drag-and-Drop for AS3 Isolib</title>
		<link>http://feedproxy.google.com/~r/masputih/~3/3J_V8cmUQFY/creating-drag-and-drop-for-as3-isolib</link>
		<comments>http://masputih.com/2010/05/creating-drag-and-drop-for-as3-isolib#comments</comments>
		<pubDate>Mon, 24 May 2010 08:18:40 +0000</pubDate>
		<dc:creator>Anggie Bratadinata</dc:creator>
				<category><![CDATA[AS3Isolib]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[as3isolib]]></category>

		<guid isPermaLink="false">http://masputih.com/2010/05/creating-drag-and-drop-for-as3-isolib</guid>
		<description><![CDATA[Some folks had asked about drag-and-drop mechanism in as3isolib discussion group. While there’s no such feature built-in in the library, it’s not hard to write it yourself. So here’s a super simple class that provides that mechanism, called DragManager. I borrowed the idea from Flex’s DragManager. Note that this class is really a simple one [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Some folks had asked about drag-and-drop mechanism in <a title="AS3 Isometric Engine" href="http://code.google.com/p/as3isolib/">as3isolib</a> <a title="discussion group" href="http://tech.groups.yahoo.com/group/as3isolib/">discussion group</a>. While there’s no such feature built-in in the library, it’s not hard to write it yourself.</p>
<p>So here’s a super simple class that provides that mechanism, called DragManager. I borrowed the idea from Flex’s DragManager. Note that this class is really a simple one and it doesn’t respect “grid” so you’ll have to modify it if you want to use it in a grid-based isometric space.  Trust me, it’s not too hard <img src='http://masputih.com/wordpress/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  </p>
<div id="attachment_738" class="wp-caption aligncenter" style="width: 300px">
	<a href="http://masputih.com/wordpress/wp-content/uploads/2010/05/dd.swf"><img src="http://masputih.com/wordpress/wp-content/uploads/2010/05/isodd-300x223.jpg" alt="" title="DragManagerDemo" width="300" height="223" class="size-medium wp-image-738" /></a>
	<p class="wp-caption-text">Click to see the demo</p>
</div>
<p><span id="more-736"></span></p>
<p>And here’s the class:</p>
<pre class="brush:as3">
package masputih.isometric.utils
{
	import as3isolib.core.IsoDisplayObject;
	import as3isolib.display.IsoView;
	import flash.display.Bitmap;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.Point;

	/**
	 * ...
	 * @author Anggie Bratadinata
	 */
	public class DragManager
	{

		private var _proxy:Sprite;
		private var _view:IsoView;
		private var _obj:IsoDisplayObject;

		public function drag(obj:IsoDisplayObject, view:IsoView):void
		{

			_view = view;
			_obj = obj;

			var bmp:Bitmap = new Bitmap(_obj.getRenderData().bitmapData)
			bmp.x = -_obj.length;
			bmp.y = -_obj.height;

			_proxy = new Sprite();
			_proxy.alpha = .5;
			_proxy.addChild(bmp);
			_proxy.addEventListener(Event.ENTER_FRAME, onProxyEnterFrame);
			_view.addChild(_proxy);

			_view.stage.addEventListener(MouseEvent.MOUSE_UP, drop);
		}

		private function onProxyEnterFrame(e:Event):void
		{
			if (_proxy != null)
			{
				_proxy.x = _view.mouseX;
				_proxy.y = _view.mouseY;
			}

		}

		private function drop(e:Event = null):void
		{
			var p:Point = new Point(_proxy.x, _proxy.y);
			p = _view.localToIso(p);

			_obj.moveTo(p.x, p.y, 0);

			//clean up
			_view.removeChild(_proxy);
			_view.stage.removeEventListener(MouseEvent.MOUSE_UP, drop);
			_proxy.removeEventListener(Event.ENTER_FRAME, onProxyEnterFrame);
			_proxy = null

		}

		public function get obj():IsoDisplayObject { return _obj; }

		/**********************************************
		 * SINGLETON CTOR
		 **********************************************/

		private static var _instance:DragManager;
		public function DragManager(enf:SingletonEnforcer)
		{

		}
		public static function getInstance():DragManager{
			if(_instance == null) _instance = new DragManager(new SingletonEnforcer());
			return _instance;
		}

	}

}

class SingletonEnforcer{};
</pre>
<h3>Sample Usage</h3>
<pre class="brush:as3">
package
{

	import as3isolib.core.IsoDisplayObject;
	import as3isolib.display.IsoView;
	import as3isolib.display.primitive.IsoBox;
	import as3isolib.display.primitive.IsoRectangle;
	import as3isolib.display.scene.IsoGrid;
	import as3isolib.display.scene.IsoScene;
	import as3isolib.graphics.SolidColorFill;
	import eDpLib.events.ProxyEvent;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import masputih.isometric.utils.DragManager;

	/**
	 * Main class
	 * @author
	 */
	public class DDTest extends Sprite
	{

		public var view:IsoView;
		public var scene:IsoScene;
		public var grid:IsoGrid;

		public function DDTest()
		{
			addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
		}

		private function onAddedToStage(e:Event):void
		{
			removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);

			view = new IsoView();
			view.setSize(600, 400);
			view.showBorder = true;

			addChild(view);

			scene = new IsoScene();
			view.addScene(scene);

			grid = new IsoGrid();
			grid.cellSize = 400;
			grid.setGridSize(1, 1);

			scene.addChild(grid);

			view.pan(0, 200);

			var obj1:IsoBox = new IsoBox();
			obj1.setSize(20, 20, 20);
			obj1.moveTo(100, 100, 0);
			obj1.fill = new SolidColorFill(0xFFFF80, 1);
			obj1.container.mouseChildren = false;
			obj1.addEventListener(MouseEvent.MOUSE_DOWN, onIsoObjMouseDown);

			var obj2:IsoRectangle = new IsoRectangle();
			obj2.setSize(20, 20,0);
			obj2.moveTo(200, 100, 0);
			obj2.fill = new SolidColorFill(0x0080FF, 1);
			obj2.container.mouseChildren = false;
			obj2.addEventListener(MouseEvent.MOUSE_DOWN, onIsoObjMouseDown);

			var obj3:IsoBox = new IsoBox();
			obj3.setSize(20, 40,30);
			obj3.moveTo(200, 200, 0);
			obj3.fill = new SolidColorFill(0x800040, 1);
			obj3.container.mouseChildren = false;
			obj3.addEventListener(MouseEvent.MOUSE_DOWN, onIsoObjMouseDown);

			scene.addChild(obj1);
			scene.addChild(obj2);
			scene.addChild(obj3);

			stage.addEventListener(Event.ENTER_FRAME, render);
		}

		private function onIsoObjMouseDown(e:ProxyEvent):void
		{
			DragManager.getInstance().drag(IsoDisplayObject(e.target), view);
		}

		private function render(e:Event):void
		{
			view.render(true);
		}

	}

}</pre>
<p>Hope you like it!</p>

<p><a href="http://feedads.g.doubleclick.net/~a/nt3vxgxJgHbhs6fz33qphBDhuqI/0/da"><img src="http://feedads.g.doubleclick.net/~a/nt3vxgxJgHbhs6fz33qphBDhuqI/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/nt3vxgxJgHbhs6fz33qphBDhuqI/1/da"><img src="http://feedads.g.doubleclick.net/~a/nt3vxgxJgHbhs6fz33qphBDhuqI/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/masputih/~4/3J_V8cmUQFY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://masputih.com/2010/05/creating-drag-and-drop-for-as3-isolib/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://masputih.com/2010/05/creating-drag-and-drop-for-as3-isolib</feedburner:origLink></item>
	</channel>
</rss>

