<?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-8657685611551902628</id><updated>2008-10-20T11:16:52.806+01:00</updated><title type='text'>Broken Button</title><subtitle type='html'>This is the blog of JC - flash and actionscript developer, interactive media architect &amp;amp; game designer.</subtitle><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8657685611551902628/posts/default'/><link rel='alternate' type='text/html' href='http://www.brokenbutton.com/blog/blog.html'/><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.brokenbutton.com/blog/atom.xml'/><author><name>JC</name><uri>http://www.blogger.com/profile/17967966771724429125</uri><email>noreply@blogger.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8657685611551902628.post-4978282695448681848</id><published>2008-09-21T03:25:00.008+01:00</published><updated>2008-09-21T05:00:58.755+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Keyboard'/><category scheme='http://www.blogger.com/atom/ns#' term='as3'/><category scheme='http://www.blogger.com/atom/ns#' term='Key'/><category scheme='http://www.blogger.com/atom/ns#' term='input'/><category scheme='http://www.blogger.com/atom/ns#' term='actionscript'/><category scheme='http://www.blogger.com/atom/ns#' term='AS2'/><category scheme='http://www.blogger.com/atom/ns#' term='missing class'/><title type='text'>Return of the Key Class to Actionscript 3.0</title><content type='html'>&lt;span style="color: rgb(0, 0, 0);font-family:verdana;" &gt;&lt;span style="font-size:85%;"&gt;This started out merely as a convenient class for handling keystrokes, and checking to see whether a particular key was being held down, mainly for arcade-type games.&lt;br /&gt;&lt;br /&gt;As I started rewriting it for public release I wondered if I could emulate &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-family:verdana;" &gt;&lt;span style="font-size:85%;"&gt;as closely as possible &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;the functionality of the old AS1/AS2 Key Class I've spent the past seven years using.&lt;/span&gt;  &lt;span style="color: rgb(0, 0, 0);"&gt;I had a play with some static methods and properties, and came up with &lt;/span&gt;&lt;a style="color: rgb(0, 0, 0); font-weight: bold;" href="http://www.brokenbutton.com/files/Key.as"&gt;this&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;You set it up like this:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;font-family:verdana;" &gt;&lt;br /&gt;&lt;br /&gt;import Key;&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;font-family:verdana;" &gt;&lt;br /&gt;Key.listen(stage);&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;br /&gt;Now place it in your game loop and use it the same way you did before:&lt;/span&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;&lt;br /&gt;&lt;br /&gt;if (Key.isDown(Key.LEFT)){trace("Left cursor key is being pressed")}&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;br /&gt;Hit me up in the comments if you have any problems with it.&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;span style="font-family:verdana;"&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/8657685611551902628/4978282695448681848/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8657685611551902628&amp;postID=4978282695448681848' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8657685611551902628/posts/default/4978282695448681848'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8657685611551902628/posts/default/4978282695448681848'/><link rel='alternate' type='text/html' href='http://www.brokenbutton.com/blog/2008/09/return-of-key-class-to-actionscript-30.html' title='Return of the Key Class to Actionscript 3.0'/><author><name>JC</name><uri>http://www.blogger.com/profile/17967966771724429125</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-8657685611551902628.post-2997623364123931300</id><published>2008-09-16T08:33:00.012+01:00</published><updated>2008-09-29T13:58:50.965+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='as3'/><category scheme='http://www.blogger.com/atom/ns#' term='workarounds'/><category scheme='http://www.blogger.com/atom/ns#' term='actionscript'/><title type='text'>ActionScript 3.0 Gotchas</title><content type='html'>&lt;span style="color: rgb(0, 0, 0);font-family:verdana;font-size:85%;"  &gt;I'm loving AS3. I have to make that clear right now. For two main reasons - Execution speed and code consistency.  Adobe really bit the bullet and made necessary changes to the language to make it self-congruent and able to stand against other object-oriented languages.&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-family:verdana;font-size:85%;"  &gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-family:verdana;font-size:85%;"  &gt;Now to moan a bit...&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-family:verdana;font-size:85%;"  &gt;  &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-family:verdana;font-size:85%;"  &gt;I've just finished my first commercial web game in AS3 and encountered several problems with the language that I'd encountered in other applications, plus a few new ones (games tend to push the platform more than other applications). So for those few that haven't made the transition from AS2 to AS3, here's a heads-up:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-family:verdana;font-size:85%;"  &gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-family:verdana;font-size:85%;"  &gt;&lt;span style="font-weight: bold;"&gt;1. &lt;/span&gt;&lt;span style="font-weight: bold;"&gt;XML.send();&lt;/span&gt; - Has gone.&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-family:verdana;font-size:85%;"  &gt;  &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-family:verdana;font-size:85%;"  &gt;No more sending raw XML data to a URL with one line of code. Nor &lt;/span&gt;  &lt;span style="color: rgb(0, 0, 0);font-family:verdana;font-size:85%;"  &gt;it seems can you do it with several unless you're using flex and can make use of the HTTPService Class. If anyone knows otherwise, please comment.&lt;br /&gt;&lt;br /&gt;Workarounds - So far I've been using sendToURL() which forces your data into name-value pairs and requires that you send the XML as one of these variables.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;2. Key behaviour &lt;/span&gt;- You can no longer query the keyboard directly and find out if a key is being held down. This is a pain if you write games. Instead you can only listen for key events.&lt;br /&gt;&lt;br /&gt;Workarounds - I've written a class that listens for events and updates a set of Booleans so that it can be queried in much the same way as the old Key.isDown method. At the moment it only works with the cursor keys. I'm going to improve it during the current project and post it here.&lt;br /&gt;&lt;br /&gt;UPDATE - &lt;a href="http://www.brokenbutton.com/blog/2008/09/return-of-key-class-to-actionscript-30.html"&gt;here it is&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;3. for..in loops no longer work with MovieClips.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-family:verdana;font-size:85%;"  &gt; Here's the situation we were in: The designer wanted to be able to take a MovieClip and place thousands of sub MovieClips at registration positions, which would then be used to create an array of co-ordinates for corresponding objects. Another caveat was that he didn't want to have to individually name each instance (obviously). The behaviour of for..in has been reduced so that class defined properties are no longer enumerable and are thus hidden. This seems to include existing stage objects.&lt;br /&gt;&lt;br /&gt;Workaround 1. You can use describeType() to pull an XML object representing the structure of the MC. But this only works with named instances. Doh!&lt;br /&gt;&lt;br /&gt;Workaround 2. Do all of this in a separate AS2 fla, and output the values via trace and copy-paste them. Ugly, but it worked.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);font-family:verdana;font-size:85%;"  &gt;4. The native tween class has been removed.&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-family:verdana;font-size:85%;"  &gt; - UPDATE - No it hasn't, I just couldn't find it first time I looked. It now seems to be documented too.&lt;a href="http://blog.greensock.com/tweenliteas3/"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://blog.greensock.com/tweenliteas3/"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);font-family:verdana;font-size:85%;"  &gt;5. and/or&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-family:verdana;font-size:85%;"  &gt; &lt;span style="font-weight: bold;"&gt;have finally been removed&lt;/span&gt; - Ok, so I forced myself to get into the habit of using "&amp;amp;&amp;amp;" and "||" when I found out that they'd been depreciated, but I think it's revealing a lot of conceit amongst those who write the specs on these languages that they've replaced two easy to read english conjunctions with these symbols.&lt;br /&gt;&lt;br /&gt;Workarounds - Well if you can't beat 'em, join 'em. To celebrate the removal of these two operators, from now on I'm going to use the conditional (?:) operator in place of "if..else" wherever I can. Hah!&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);font-family:verdana;font-size:85%;"  &gt;6. Code bloat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-family:verdana;font-size:85%;"  &gt;&lt;span style="font-weight: bold;"&gt;. &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-family:verdana;font-size:85%;"  &gt;- I'm starting to wonder how many times a line of AS2 is going to have to be replaced with either two lines of AS3 or an entire custom class. Some code bloat is a necessary evil when it comes to good coding practice, but then nice compact code is a great practice in itself.&lt;br /&gt;&lt;br /&gt;Workarounds - I don't know...quit coding and go and live on a technology-free commune?&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-family:verdana;font-size:85%;"  &gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;7. Preloading. &lt;/span&gt;- AS3 has introduced a whole new load of issues with preloading, the main one being that your document class has to be exported on the first frame.&lt;br /&gt;&lt;br /&gt;Workarounds - Whilst it's possible to have a &lt;a href="http://www.bit-101.com/blog/?p=946"&gt;movie preload itself effectively&lt;/a&gt;, I find it best to have a separate swf preloader. &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-family:verdana;font-size:85%;"  &gt;There's a good tutorial on this &lt;a href="http://theflashblog.com/?p=438"&gt;here&lt;/a&gt;. &lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:85%;" &gt;This bypasses a few issues, and gives you more options like deploying your main swf on its own when a preloader isn't needed, or even having your preloader manage multiple files if necessary.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);font-size:85%;" &gt;8. Bitmap scaling bug - &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:85%;" &gt;I'll write more on this in another post, but it seems that if the document class pulls a bitmap into the display list, and there's an MC above it with certain filter effects, the scaling doesn't work (the bitmap scales, but the data inside it doesn't)&lt;br /&gt;&lt;br /&gt;Workarounds - Either bind your baseclass to a movieclip instead, or avoid using filters in other display objects.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Hope some of this helps somebody.&lt;br /&gt;&lt;br /&gt;More to come on the bitmap scaling bug, the game, and the enormous fun you can have with conditional operators in later posts.&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/8657685611551902628/2997623364123931300/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8657685611551902628&amp;postID=2997623364123931300' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8657685611551902628/posts/default/2997623364123931300'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8657685611551902628/posts/default/2997623364123931300'/><link rel='alternate' type='text/html' href='http://www.brokenbutton.com/blog/2008/09/actionscript-30-gotchas.html' title='ActionScript 3.0 Gotchas'/><author><name>JC</name><uri>http://www.blogger.com/profile/17967966771724429125</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-8657685611551902628.post-5042571665751262139</id><published>2008-09-16T08:08:00.004+01:00</published><updated>2008-09-21T04:35:10.611+01:00</updated><title type='text'>First Post</title><content type='html'>&lt;span style="color: rgb(0, 0, 0);font-size:85%;" &gt;&lt;span style="font-family:verdana;"&gt;It's about time I started a blog.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;I'll try and keep posts regular, informative, entertaining and relevant to my work.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;This post isn't a very good example.&lt;/span&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/8657685611551902628/5042571665751262139/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8657685611551902628&amp;postID=5042571665751262139' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8657685611551902628/posts/default/5042571665751262139'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8657685611551902628/posts/default/5042571665751262139'/><link rel='alternate' type='text/html' href='http://www.brokenbutton.com/blog/2008/09/first-post.html' title='First Post'/><author><name>JC</name><uri>http://www.blogger.com/profile/17967966771724429125</uri><email>noreply@blogger.com</email></author></entry></feed>