<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: 4k &#8211; Tiny Keyboard Handler</title>
	<atom:link href="http://prototyprally.com/4k-tiny-keyboard-handler/feed/" rel="self" type="application/rss+xml" />
	<link>http://prototyprally.com/4k-tiny-keyboard-handler/</link>
	<description>rapid prototyping of games using flash</description>
	<lastBuildDate>Thu, 29 Jul 2010 02:42:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: grapefrukt</title>
		<link>http://prototyprally.com/4k-tiny-keyboard-handler/comment-page-1/#comment-6223</link>
		<dc:creator>grapefrukt</dc:creator>
		<pubDate>Tue, 10 Mar 2009 15:46:08 +0000</pubDate>
		<guid isPermaLink="false">http://prototyprally.com/?p=232#comment-6223</guid>
		<description>that&#039;s fantastic, and here I thought this couldn&#039;t get more ugly. nice work!</description>
		<content:encoded><![CDATA[<p>that&#8217;s fantastic, and here I thought this couldn&#8217;t get more ugly. nice work!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Clint</title>
		<link>http://prototyprally.com/4k-tiny-keyboard-handler/comment-page-1/#comment-6222</link>
		<dc:creator>Clint</dc:creator>
		<pubDate>Tue, 10 Mar 2009 15:42:11 +0000</pubDate>
		<guid isPermaLink="false">http://prototyprally.com/?p=232#comment-6222</guid>
		<description>Hey, great tips! I used this technique in my 4k game entry, and actually improved on it a little. In the keyboard handler, change &quot;true&quot; and &quot;false&quot; to be 1 and 0, then in your update function, use:

block.x += k[39] - k[37]; // Right - Left
block.y += k[40] - k[38]; // Down - Up

You have to initialize your k array to be equal to a string of 40 or 50 0&#039;s, but I found that compresses really well, and the bytes saved are more than worth it.

private var k:Array = [0,0,0,0,0,0,0 .... ,0,0,0];

Cheers!

--clint</description>
		<content:encoded><![CDATA[<p>Hey, great tips! I used this technique in my 4k game entry, and actually improved on it a little. In the keyboard handler, change &#8220;true&#8221; and &#8220;false&#8221; to be 1 and 0, then in your update function, use:</p>
<p>block.x += k[39] &#8211; k[37]; // Right &#8211; Left<br />
block.y += k[40] &#8211; k[38]; // Down &#8211; Up</p>
<p>You have to initialize your k array to be equal to a string of 40 or 50 0&#8217;s, but I found that compresses really well, and the bytes saved are more than worth it.</p>
<p>private var k:Array = [0,0,0,0,0,0,0 .... ,0,0,0];</p>
<p>Cheers!</p>
<p>&#8211;clint</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Richard Davey</title>
		<link>http://prototyprally.com/4k-tiny-keyboard-handler/comment-page-1/#comment-6214</link>
		<dc:creator>Richard Davey</dc:creator>
		<pubDate>Tue, 24 Feb 2009 11:59:08 +0000</pubDate>
		<guid isPermaLink="false">http://prototyprally.com/?p=232#comment-6214</guid>
		<description>Nice one :) I do use un-typed vars, but not until the very end because it stops lots of the context sensitive assists from working in FlashDevelop! (same for strings replacing constants)</description>
		<content:encoded><![CDATA[<p>Nice one <img src='http://prototyprally.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  I do use un-typed vars, but not until the very end because it stops lots of the context sensitive assists from working in FlashDevelop! (same for strings replacing constants)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: grapefrukt</title>
		<link>http://prototyprally.com/4k-tiny-keyboard-handler/comment-page-1/#comment-6213</link>
		<dc:creator>grapefrukt</dc:creator>
		<pubDate>Tue, 24 Feb 2009 10:03:56 +0000</pubDate>
		<guid isPermaLink="false">http://prototyprally.com/?p=232#comment-6213</guid>
		<description>I changed the event handlers into inline functions and that saved me a good 17 bytes. Thanks Richard. Using an array instead of an object actually added 2 bytes for me. 
You really should try using untyped arguments and plain strings instead of the constants, that&#039;ll save you something like 11 bytes!</description>
		<content:encoded><![CDATA[<p>I changed the event handlers into inline functions and that saved me a good 17 bytes. Thanks Richard. Using an array instead of an object actually added 2 bytes for me.<br />
You really should try using untyped arguments and plain strings instead of the constants, that&#8217;ll save you something like 11 bytes!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Richard Davey</title>
		<link>http://prototyprally.com/4k-tiny-keyboard-handler/comment-page-1/#comment-6212</link>
		<dc:creator>Richard Davey</dc:creator>
		<pubDate>Mon, 23 Feb 2009 10:25:59 +0000</pubDate>
		<guid isPermaLink="false">http://prototyprally.com/?p=232#comment-6212</guid>
		<description>If you&#039;d like to save yourself even more bytes you could do the following: 1) Use an array instead of an Object and 2) Wrap the function into the event listener call itself. Functions add quite a lot of extra bytes to the SWF, the less of them you have in your final game, the smaller it will be! Here&#039;s the code I use:
			stage.addEventListener(KeyboardEvent.KEY_DOWN, function (e:KeyboardEvent) { keys[e.keyCode] = true; });
			stage.addEventListener(KeyboardEvent.KEY_UP, function (e:KeyboardEvent) { keys[e.keyCode] = false; } );</description>
		<content:encoded><![CDATA[<p>If you&#8217;d like to save yourself even more bytes you could do the following: 1) Use an array instead of an Object and 2) Wrap the function into the event listener call itself. Functions add quite a lot of extra bytes to the SWF, the less of them you have in your final game, the smaller it will be! Here&#8217;s the code I use:<br />
			stage.addEventListener(KeyboardEvent.KEY_DOWN, function (e:KeyboardEvent) { keys[e.keyCode] = true; });<br />
			stage.addEventListener(KeyboardEvent.KEY_UP, function (e:KeyboardEvent) { keys[e.keyCode] = false; } );</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: grapefrukt</title>
		<link>http://prototyprally.com/4k-tiny-keyboard-handler/comment-page-1/#comment-6203</link>
		<dc:creator>grapefrukt</dc:creator>
		<pubDate>Sat, 14 Feb 2009 19:20:17 +0000</pubDate>
		<guid isPermaLink="false">http://prototyprally.com/?p=232#comment-6203</guid>
		<description>i think that&#039;s because variables without var are in the global scope, so they might get handled a bit differently.</description>
		<content:encoded><![CDATA[<p>i think that&#8217;s because variables without var are in the global scope, so they might get handled a bit differently.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: s</title>
		<link>http://prototyprally.com/4k-tiny-keyboard-handler/comment-page-1/#comment-6202</link>
		<dc:creator>s</dc:creator>
		<pubDate>Fri, 13 Feb 2009 15:12:59 +0000</pubDate>
		<guid isPermaLink="false">http://prototyprally.com/?p=232#comment-6202</guid>
		<description>Why not just go with as2 then? I think I will.

One thing I noticed (flash 8, as2) is that it&#039;s not just about saving characters.

If you declare varibable with var, the swf gets smaller, than if you don&#039;t. Even though it&#039;s the exact same with less characters without it.</description>
		<content:encoded><![CDATA[<p>Why not just go with as2 then? I think I will.</p>
<p>One thing I noticed (flash 8, as2) is that it&#8217;s not just about saving characters.</p>
<p>If you declare varibable with var, the swf gets smaller, than if you don&#8217;t. Even though it&#8217;s the exact same with less characters without it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: grapefrukt</title>
		<link>http://prototyprally.com/4k-tiny-keyboard-handler/comment-page-1/#comment-6201</link>
		<dc:creator>grapefrukt</dc:creator>
		<pubDate>Fri, 13 Feb 2009 11:27:23 +0000</pubDate>
		<guid isPermaLink="false">http://prototyprally.com/?p=232#comment-6201</guid>
		<description>Using short variable names made more sense when the swf wasn&#039;t compressed, back in the Flash 6 days. Now it should be replaced with some neat compression token, saving you most of that space. But, as you say, they *do* get embedded into the file, so a shorter name should mean a few bytes less in your file. 

Also note that the mxmlc compiler, does *not* remove trace statements when you compile for release. These add a handful of bytes each to your code, so make sure you remove them!

The flash authoring tool has an option to do this (omit traces) but mxmlc lacks this for some reason.</description>
		<content:encoded><![CDATA[<p>Using short variable names made more sense when the swf wasn&#8217;t compressed, back in the Flash 6 days. Now it should be replaced with some neat compression token, saving you most of that space. But, as you say, they *do* get embedded into the file, so a shorter name should mean a few bytes less in your file. </p>
<p>Also note that the mxmlc compiler, does *not* remove trace statements when you compile for release. These add a handful of bytes each to your code, so make sure you remove them!</p>
<p>The flash authoring tool has an option to do this (omit traces) but mxmlc lacks this for some reason.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kian</title>
		<link>http://prototyprally.com/4k-tiny-keyboard-handler/comment-page-1/#comment-6200</link>
		<dc:creator>Kian</dc:creator>
		<pubDate>Fri, 13 Feb 2009 11:13:36 +0000</pubDate>
		<guid isPermaLink="false">http://prototyprally.com/?p=232#comment-6200</guid>
		<description>Beautiful! :D One thing; have you tried using
really short variable and function names? I don&#039;t
know about AS3, but in AS2 variable names stay intact
in the actual .swf-file (which is just ridiculous) and
the length of a name even affected performance 
at least, that&#039;s what all the cool people said).</description>
		<content:encoded><![CDATA[<p>Beautiful! <img src='http://prototyprally.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  One thing; have you tried using<br />
really short variable and function names? I don&#8217;t<br />
know about AS3, but in AS2 variable names stay intact<br />
in the actual .swf-file (which is just ridiculous) and<br />
the length of a name even affected performance<br />
at least, that&#8217;s what all the cool people said).</p>
]]></content:encoded>
	</item>
</channel>
</rss>
