<?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>The Flex Guy</title>
	<atom:link href="http://www.theflexguy.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.theflexguy.com</link>
	<description>I&#039;m addicted to Flex, this is my therapy.</description>
	<lastBuildDate>Thu, 16 May 2013 22:16:12 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>How to create a default date range for google search</title>
		<link>http://www.theflexguy.com/2013/05/16/how-to-create-a-default-date-range-for-google-search/</link>
		<comments>http://www.theflexguy.com/2013/05/16/how-to-create-a-default-date-range-for-google-search/#comments</comments>
		<pubDate>Thu, 16 May 2013 22:08:46 +0000</pubDate>
		<dc:creator>marty</dc:creator>
				<category><![CDATA[Random]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.theflexguy.com/?p=159</guid>
		<description><![CDATA[Something I have been wanting a LONG time has been the ability to set my google searches to default to Past Year. Since I do a lot of software related searches, results from 5 years ago are usually irrelevant. I did a search on the structure of google search urls and found this post: http://www.our-picks.com/archives/2007/01/30/google-search-urls-revealed-or-how-to-create-your-own-search-url/ [...]]]></description>
				<content:encoded><![CDATA[<p>Something I have been wanting a LONG time has been the ability to set my google searches to default to Past Year. Since I do a lot of software related searches, results from 5 years ago are usually irrelevant.</p>
<p><img class="alignnone  wp-image-163" title="Why can't it default to search the past year!?" alt="" src="http://www.theflexguy.com/wp-content/uploads/2013/05/GooglePastYear1.png" width="473" height="86" /></p>
<p>I did a search on the structure of google search urls and found this post: <a href="http://www.our-picks.com/archives/2007/01/30/google-search-urls-revealed-or-how-to-create-your-own-search-url/" target="_blank">http://www.our-picks.com/archives/2007/01/30/google-search-urls-revealed-or-how-to-create-your-own-search-url/</a></p>
<p>Here&#8217;s how to set up Chrome to use the past year as your default search range:</p>
<ol>
<li>Go to settings.</li>
<li>Under the Search heading, click the Manage Search Engines&#8230; button.</li>
<li>Scroll to the bottom of the page, so you see the 3 fields for entering your own search engine.</li>
<li>Put these in the three fields:
<ol>
<li>
<pre>GoogleYear</pre>
</li>
<li>
<pre>search.google.com</pre>
</li>
<li style="text-align: left;">
<pre>{google:baseURL}search?q=%s&amp;as_qdr=y&amp;{google:RLZ}{google:acceptedSuggestion}{google:originalQueryForSuggestion}{google:assistedQueryStats}{google:searchFieldtrialParameter}{google:searchClient}{google:sourceId}{google:instantExtendedEnabledParameter}ie={inputEncoding}</pre>
</li>
</ol>
</li>
<li>Click the &#8220;Make default&#8221; button that appears at the end of the row you just made.</li>
<li>Click DONE and you&#8217;re set. Now your omnibox will always default search results to the past year unless you change it the usual way from the Search Tools at the top of the results page.</li>
</ol>
<p>For other browsers, you can do something similar with a bookmark to the following: http://www.google.com/search?as_qdr=y or by setting up a custom search engine similarly.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.theflexguy.com/2013/05/16/how-to-create-a-default-date-range-for-google-search/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using SourceMate 3.0 to create code bookmarks</title>
		<link>http://www.theflexguy.com/2012/08/14/sourcemate-code-bookmarks/</link>
		<comments>http://www.theflexguy.com/2012/08/14/sourcemate-code-bookmarks/#comments</comments>
		<pubDate>Tue, 14 Aug 2012 19:12:26 +0000</pubDate>
		<dc:creator>marty</dc:creator>
				<category><![CDATA[Flash Builder]]></category>
		<category><![CDATA[Flex4]]></category>

		<guid isPermaLink="false">http://www.theflexguy.com/?p=151</guid>
		<description><![CDATA[Something I&#8217;ve been wanting for a while was a slick way to have &#8220;bookmarks&#8221; in my code to help me jump quickly to certain places in the source files. It&#8217;s not uncommon for me to have a long list of files open in Flash Builder. Some files are unnecessarily large, with far more functions than [...]]]></description>
				<content:encoded><![CDATA[<p>Something I&#8217;ve been wanting for a while was a slick way to have &#8220;bookmarks&#8221; in my code to help me jump quickly to certain places in the source files. It&#8217;s not uncommon for me to have a long list of files open in Flash Builder. Some files are unnecessarily large, with far more functions than should be there. These problems are something we are all guilty of at one point or another.</p>
<p>I recently installed the trial version of <a title="SourceMate 3" href="http://www.elementriver.com/sourcemate3" target="_blank">SourceMate 3.0 from Element River</a>. It&#8217;s got a ton of productivity enhancements for Flash Builder 4.5+. It doesn&#8217;t have a bookmarks feature, but what does it does have is task tags. I really like this feature in general but I found it can be used to create bookmarks.</p>
<ol>
<li>I created a new tag &#8220;BKMK&#8221; in the SourceMate tags preferences (Preferences &gt; SourceMate &gt; TaskTags).
<div id="attachment_152" class="wp-caption alignnone" style="width: 310px"><a href="http://www.theflexguy.com/wp-content/uploads/2012/08/SourceMateTaskTags.jpg"><img class="size-medium wp-image-152 " title="SourceMateTaskTags" src="http://www.theflexguy.com/wp-content/uploads/2012/08/SourceMateTaskTags-300x259.jpg" alt="" width="300" height="259" /></a><p class="wp-caption-text">Add &#8220;BKMK&#8221; task tag</p></div>
<p>Now, when I add a comment that starts with BKMK, it will show up in the tasks view.<br />
<code>// BKMK Place where I go to often</code></li>
<li>Then, using the menu for the tasks view, I showed a new view and named it Bookmarks.
<p><div id="attachment_153" class="wp-caption alignnone" style="width: 310px"><a href="http://www.theflexguy.com/wp-content/uploads/2012/08/NewTasksView.jpg"><img class="size-medium wp-image-153 " title="NewTasksView" src="http://www.theflexguy.com/wp-content/uploads/2012/08/NewTasksView-300x53.jpg" alt="" width="300" height="53" /></a><p class="wp-caption-text">Create a new Tasks view</p></div></li>
<li>I chose Configure Contents&#8230; from the menu and created a new configuration called Bookmarks. For that configuration, I added Text: contains BKMK.
<p><div id="attachment_154" class="wp-caption alignnone" style="width: 310px"><a href="http://www.theflexguy.com/wp-content/uploads/2012/08/ConfigureContents.jpg"><img class="size-medium wp-image-154" title="ConfigureContents" src="http://www.theflexguy.com/wp-content/uploads/2012/08/ConfigureContents-300x190.jpg" alt="" width="300" height="190" /></a><p class="wp-caption-text">Create new Bookmarks configuration</p></div></li>
<li>Leaving that dialog and returning to the Flash Builder window, I chose Show &gt; Bookmarks for that tasks view and viola, this Bookmarks view will always show the list of BKMK items I&#8217;ve placed inline in my code.
<p><div id="attachment_155" class="wp-caption alignnone" style="width: 310px"><a href="http://www.theflexguy.com/wp-content/uploads/2012/08/ShowBookmarks.jpg"><img class="size-medium wp-image-155" title="ShowBookmarks" src="http://www.theflexguy.com/wp-content/uploads/2012/08/ShowBookmarks-300x97.jpg" alt="" width="300" height="97" /></a><p class="wp-caption-text">Show Bookmarks configuration in the new view</p></div></li>
</ol>
<p>This requires adding lines to the source code, so unlike breakpoints, it requires modification but can still be a pretty good workaround for the time being.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.theflexguy.com/2012/08/14/sourcemate-code-bookmarks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jenkins, Windows Server 2008 R2 and Git with SSH</title>
		<link>http://www.theflexguy.com/2012/07/29/jenkins-windows-git/</link>
		<comments>http://www.theflexguy.com/2012/07/29/jenkins-windows-git/#comments</comments>
		<pubDate>Sun, 29 Jul 2012 06:26:55 +0000</pubDate>
		<dc:creator>marty</dc:creator>
				<category><![CDATA[Git]]></category>
		<category><![CDATA[Jenkins]]></category>

		<guid isPermaLink="false">http://www.theflexguy.com/?p=146</guid>
		<description><![CDATA[The team I&#8217;m on have been using Hudson for our builds for quite a while and really like it. A while back, something went terribly wrong and Hudson, well, let&#8217;s just say he passed away. We tried and tried to bring him back but after a week of doing all we could, we had to [...]]]></description>
				<content:encoded><![CDATA[<p>The team I&#8217;m on have been using Hudson for our builds for quite a while and really like it. A while back, something went terribly wrong and Hudson, well, let&#8217;s just say he passed away. We tried and tried to bring him back but after a week of doing all we could, we had to call the time of death.</p>
<p>This was a new beginning though, because we could move over to Jenkins and be one of the modern cool kids. Yeah, not quite as plug-and-play as we hoped. We spent many days trying to get it to work. Through the process, we hit about every error it can spit out. I&#8217;ll try to detail what we ran into and how we solved it (to the best of my memory) in another post, if I have the time. In this post, I&#8217;ll just summarize the final solution in hopes it will help someone else out there.</p>
<h4>Our environment</h4>
<p>We&#8217;re running Windows 2008 R2 Datacenter SP1 on a virtual machine in Amazons Cloud. Our repository is hosted at codesion.com. After looking around the web for solutions to the errors I ran into, I wished we used GitHub since it seems like EVERYONE else out there does. That&#8217;s what most of the solutions are for. Luckily, codesion has enough on their site for me to wrap my head around what I needed to do. We have Git Bash installed on the server.</p>
<h4>Install Jenkins</h4>
<p>Do everything under the same account from now on, as long as you&#8217;re getting Jenkins all configured. Let&#8217;s say you&#8217;ve created a unique account for Jenkins so your team can all log in to the same account when working on Jenkins. That username is jenkinsuser for the examples here. Once that user is all set up, you can install the Jenkins application. This part is pretty straight forward so I won&#8217;t go into detail.</p>
<h4>Set the HOME environment variable</h4>
<p>Make sure the HOME environment variable is set to the jenkinsuser User directory. I&#8217;m actually not entirely sure it wasn&#8217;t in our case, but I saw some posts that stated it doesn&#8217;t do it automatically.</p>
<h4>Create SSH Keys</h4>
<p>This was the biggest stumbling block for me. We spent forever trying to get it to authenticate correctly. So, to summarize, you start Git Bash and follow the instructions here: <a title="Generating SSH Keys" href="https://help.github.com/articles/generating-ssh-keys" target="_blank">https://help.github.com/articles/generating-ssh-keys</a>. Don&#8217;t set a passphrase! It will save you time and frustration later.</p>
<p>In that github link, it talks about supplying your public SSH key. In codesion, this is under My Settings &gt; SSH Keys. Then, go to the projects tab and click on the project you&#8217;re going to be building with Jenkins. On the right, is a services section where you can expand Git and see the ssh url. Copy this down because you&#8217;ll need it for Jenkins. It will probably say something like ssh://git_mydomain@mydomain.git.codesion.com/myproject.git.</p>
<h4>Configure Jenkins</h4>
<p>In Jenkins, you can now set up your project to connect to your git repo for builds. Under the project configuration, there will be a Source Code Management section. Choose Git and paste the ssh url from earlier into the Repository URL field. In the Build section, I just added a Windows batch command of <em>echo HEY, I&#8217;M BUILDING, FINALLY!..</em>. That&#8217;s just so you can see that it got to that point and all was well. If you&#8217;re lucky, you can click SAVE and then build now and it will work. Check the Console of the build to see errors.</p>
<p>I wasn&#8217;t lucky. I ran into some other issues. The first, was that when I went to Manage Jenkins &gt; Configure Jenkins, then scrolled down to the Git section, it had git.exe as the path to Git executable. I had to change this to the full path, despite what one blog post cautioned against.</p>
<p>The final one, that may have been what fixed many of the other issues, was to install the Jenkins git plugin instead of the Hudson version it comes with. Not sure why that isn&#8217;t default, but whatever. You can go to Manage Jenkins &gt; Manage Plugins and choose the Installed tab. You should see your Git plugin there. Uncheck the check box to disable it. Restart Jenkins so it&#8217;s happy. Then, go here: <a href="http://updates.jenkins-ci.org/download/plugins/git/" target="_blank">http://updates.jenkins-ci.org/download/plugins/git/</a> to download the latest git.hpi file.</p>
<p>Go back to Jenkins then and to the Manage Plugins area, to the Advanced tab. There you&#8217;ll see where you can upload the file you just downloaded. Once it&#8217;s installed, you&#8217;ll have to back to that page, to the Installed tab and enable the plugin. Then back to the configure page for your project and enter the ssh url into the Git section again. This fixed it for me.</p>
<p>I hope this helps someone else out there. I&#8217;d love to save someone days or weeks of banging their head against a wall.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.theflexguy.com/2012/07/29/jenkins-windows-git/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New position, new learnings</title>
		<link>http://www.theflexguy.com/2012/06/30/new-position-new-learnings/</link>
		<comments>http://www.theflexguy.com/2012/06/30/new-position-new-learnings/#comments</comments>
		<pubDate>Sat, 30 Jun 2012 05:14:28 +0000</pubDate>
		<dc:creator>marty</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.theflexguy.com/?p=138</guid>
		<description><![CDATA[I&#8217;ve landed a new job with Silicon Publishing Inc. Silicon Publishing creates custom InDesign solutions for companies. I&#8217;ve been working on a web to print designer tool over the last 6+ months that will allow users to create custom photobooks, cards, envelopes, and other custom print products. It&#8217;s been a great learning experience so far. [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.siliconpublishing.com"><img class="alignright size-full wp-image-139" title="Silicon Publishing" src="http://www.theflexguy.com/wp-content/uploads/2012/06/spi_logo_large.png" alt="Silicon Publishing logo" width="200" height="45" /></a>I&#8217;ve landed a new job with <a title="Silicon Publishing website" href="http://siliconpublishing.com/" target="_blank">Silicon Publishing Inc</a>. Silicon Publishing creates custom InDesign solutions for companies. I&#8217;ve been working on a web to print designer tool over the last 6+ months that will allow users to create custom photobooks, cards, envelopes, and other custom print products.</p>
<p>It&#8217;s been a great learning experience so far. I&#8217;ve learned a lot about working with TLF, images, sizing, template information generated from InDesign documents and more. I&#8217;ve used far more math than I ever thought I&#8217;d use in a lifetime. It&#8217;s allowed me to be creative in many new ways.</p>
<p>I&#8217;ve had to solve a lot of problems that were quite tough for me at the time until I wrapped my head around it. I suppose that&#8217;s how most problems are. Once you get the solution, you think &#8220;wow, I can&#8217;t believe it took me that long to get to such a simple solution.&#8221;</p>
<p>It&#8217;s been a little over a year since I blogged last. I&#8217;m not a very consistent blogger as you may have noticed. I&#8217;d like to start posting things I learn and problems I solve. We&#8217;ll see how that goes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.theflexguy.com/2012/06/30/new-position-new-learnings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More thoughts on caching in Flex</title>
		<link>http://www.theflexguy.com/2011/06/18/more-thoughts-on-caching-in-flex/</link>
		<comments>http://www.theflexguy.com/2011/06/18/more-thoughts-on-caching-in-flex/#comments</comments>
		<pubDate>Sat, 18 Jun 2011 19:00:04 +0000</pubDate>
		<dc:creator>marty</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://www.theflexguy.com/?p=135</guid>
		<description><![CDATA[As I discussed previously, caching can have it&#8217;s advantages.  It makes referencing objects and binding much more straight forward.  Unfortunately, it comes at a performance cost.  Since I&#8217;ve been using caching, there are some important things to keep in mind when you use caching to make sure your data sticks around and your performance doesn&#8217;t [...]]]></description>
				<content:encoded><![CDATA[<p>As I discussed previously, caching can have it&#8217;s advantages.  It makes referencing objects and binding much more straight forward.  Unfortunately, it comes at a performance cost.  Since I&#8217;ve been using caching, there are some important things to keep in mind when you use caching to make sure your data sticks around and your performance doesn&#8217;t suffer any more than it has to.<span id="more-135"></span></p>
<p>If your data coming from the backend is always the same structure and all the properties of your value objects are populated, the following gotchas probably won&#8217;t apply.  For me, I&#8217;m working with some complex objects that can have a lot of data associated with it.  Because of that, the objects returned from the server can have different amounts of data populated.</p>
<p>Let&#8217;s say you&#8217;re working with Contacts again.  If your contact table had the following fields that matched to basic properties of your value object, you&#8217;d be fine.</p>
<p>contactId, firstName, lastName, phone, email, street1, street2, city, state, zip</p>
<p>But what if your object was a little more complex, like this:</p>
<p>contactId:int<br />
firstName:String<br />
lastName:String<br />
phone:String<br />
email:String<br />
address:Address<br />
notes:ArrayCollection of potentially long Strings<br />
purchases:ArrayCollection of Purchase<br />
referrals:ArrayCollection of Contact</p>
<p>Now, the API for the database might need to have more than a simple getContacts call.  Maybe you need a getSimpleContacts that just populates the id, name, and contact info.  This would be useful for getting the list of your contacts to put in a list.  Then when you select a contact, you could make a getFullContact call so that potentially large sets of data don&#8217;t have to be sent if they might not be needed.</p>
<p>If this were the case, you&#8217;d make the initial getSimpleContacts call to populate your list.  That would sync the objects to your data cache, with null values for the properties that are ArrayCollections.  Then as you select items, those null values would get overwritten with the real data in the cache.  Here&#8217;s the updateProperties method in the cache I&#8217;ve been using:</p>
<pre>private function updateProperties(itemA:Object, itemB:Object):void
{	
     for each (var property:Property in info.getProperties())
     {
          if (property.readable &amp;&amp; property.writable)
          {
               property.setValue(itemA, property.getValue(itemB));
          }
     }
}</pre>
<p>It simply copies the new data from the new object (itemB) to the cached object (itemA).  That seems simple and elegant.</p>
<p>If you have the multiple APIs I talked about earlier, this can pose a problem.  Let&#8217;s say you open the application, getSimpleContacts is called to populate the basic list, you select a couple which shows all the contacts information so you use the getFullContact API.  The Contact object comes back with all the fields populated.  You sync the contact object using the cache and all the values are copied over to the cached object.  This is good because now, the object in the cache is fully populated so wherever you use it in your application, you&#8217;ve already got all the data.  Maybe in the time since you called getSimpleContacts and getFullContact, the phone number was updated, so that is updated in the cached contact as well.</p>
<p>Now, you go back to your list and to be sure you get any contacts that have been added since you last looked at the list, you make the getSimpleContacts call again.  The contacts come back and you sync each one with the cache so any updates will be reflected in the cached contacts.</p>
<p>Do you see a problem with the updateProperties method in this case?  The simple contact objects will still have all the property definitions, but since the API only returns the basic stuff, the new object will have null values for notes, purchases and referrals.  The updateProperties method will copy those null values over, clearing those populated values you had.</p>
<p>As long as the API will never return null values for properties the API provides, you could add a check to the if statement that only does the copy if the new value is not null:</p>
<pre>if (property.readable &amp;&amp; property.writable &amp;&amp; property.getValue(itemB) != null)
{
     property.setValue(itemA, property.getValue(itemB));
}</pre>
<p>If the data your server provides has a dateModified field that gets updated whenever any property of the object changes, you could make a custom cache for that dataType that compares the dateModified values of the old and new data.  If the dateModified is the same, you can skip copying over the basic data, since all APIs retrieve that in our example, and just copy the last three properties that might be null.  You could check for nulls as well to further reduce the work involved.  Skipping all that data copying if you know it wasn&#8217;t modified might seem trivial for one object but imagine if you retrieved 1000 contacts and synced them all with the cache.  Skipping the copying for the majority of your data would vastly improve the time it takes to process all those objects.</p>
<p>If you&#8217;re working on an enterprise application like I am, you&#8217;ll most likely appreciate the performance improvement and the caching mechanism I&#8217;ve described.  When you&#8217;re working with really big data sets, every little bit of processing time saved on each item can translate to noticeable improvements in the performance of your application.  Mobile applications also benefit from any performance improvement you can give it.</p>
<p>Do you have other ideas on caching or performance improvements when dealing with large amounts of data?  I&#8217;d love to hear them in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.theflexguy.com/2011/06/18/more-thoughts-on-caching-in-flex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Some thoughts on caching objects in Flex</title>
		<link>http://www.theflexguy.com/2011/06/17/some-thoughts-on-caching/</link>
		<comments>http://www.theflexguy.com/2011/06/17/some-thoughts-on-caching/#comments</comments>
		<pubDate>Fri, 17 Jun 2011 19:15:49 +0000</pubDate>
		<dc:creator>marty</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[caching]]></category>

		<guid isPermaLink="false">http://www.theflexguy.com/?p=134</guid>
		<description><![CDATA[The project I&#8217;ve been working on for a while now uses caching.  This means that the application will store the objects returned from the server in a DataCache and anytime objects are returned from the server, they are synced with the DataCache. This has the advantage of ensuring you&#8217;re always updating existing objects instead of [...]]]></description>
				<content:encoded><![CDATA[<p>The project I&#8217;ve been working on for a while now uses caching.  This means that the application will store the objects returned from the server in a DataCache and anytime objects are returned from the server, they are synced with the DataCache.<span id="more-134"></span> This has the advantage of ensuring you&#8217;re always updating existing objects instead of just swapping objects out.  The reason that can be an advantage is because if you have views bound to those objects or, especially, properties of those objects, the view won&#8217;t end up bound to an object that no longer is relevant.  This is an important concept so I&#8217;ll elaborate.</p>
<p>Lets say you have an application that tracks contacts.  The Contact object has a number of properties and some of the properties are custom classes themselves, such as an Address class.  Your application displays the contact information for the contact and you bind the address view to properties of the address property, like this:</p>
<pre>&lt;s:Label id="street1" text="{contact.address.street1}"/&gt;</pre>
<p>At first glance, most people would think this is just fine.  But here&#8217;s the scenario where this becomes an issue:</p>
<p>Let&#8217;s say the contact application doesn&#8217;t cache the contact objects.  Instead, you just overwrite the original data with the updated data.  It&#8217;s fast and simple.  There is probably a var called contacts in a model that the rest of your application references to display information about the contacts.</p>
<p>You&#8217;re open the application and on startup, it fetches all the contacts.  You select one of the contacts to view all the details.  The label that displays the street binds to the contact you selected and displays the data.  Then your application fetches the contacts from the server again, in case someone else has made changes to the contacts.  This contact (we&#8217;ll call him Henry) lived on River Rd. but recently moved to live on Oak St.  While your application was open, someone else updated his address.  Now, when the application on your computer goes out and fetches the contact again, it replaces that object with the new contact object.  It&#8217;s the same information but a different object in memory.</p>
<p>Here&#8217;s where the problem comes into play.  The Label was bound to the street1 property of the address property of the original contact object.  That object still exists with the original address and street1 values, and the Label is still bound to it.  The new object that has replaced it happens to have the same name and contactId, etc. but ActionScript doesn&#8217;t assume anything so the label ends up showing out of date information even though you&#8217;ve fetched the updated information.</p>
<p>If the contact object was cached, what would end up happening is that the Label would bind to a property of the contact which was stored in the cache.  When the new object came back from the server, it would be sent to the cache to be syncronized.  The cache would find the contact object with the same contactId and copy values from the new object to the one already in the cache.  Any properties that are not base objects like String, int, etc. would need to be cached and synced as well.  So your Address instance associated with Henry&#8217;s Contact instance would be updated in the cache too.  That way, the Contact instance is always the same object in memory and the Address instance used for the address property would always be the same object in memory as well.</p>
<p>This method takes some more time to keep the objects up to date but makes it much simpler when it comes to referencing those objects throughout your application.  The flip side would be to do the basic swap of data, but use events to notify the rest of the application that things have changed and carefully deal with that change appropriately by reassigning references wherever needed.  That way would be much more complex on your part but could potentially be much faster than using the cache.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.theflexguy.com/2011/06/17/some-thoughts-on-caching/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ArrayCollection contains() uses your sort!</title>
		<link>http://www.theflexguy.com/2011/05/24/arraycollection-uses-your-sort/</link>
		<comments>http://www.theflexguy.com/2011/05/24/arraycollection-uses-your-sort/#comments</comments>
		<pubDate>Tue, 24 May 2011 23:21:33 +0000</pubDate>
		<dc:creator>marty</dc:creator>
				<category><![CDATA[Flex4]]></category>
		<category><![CDATA[ArrayCollection]]></category>
		<category><![CDATA[contains]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[sort]]></category>

		<guid isPermaLink="false">http://www.theflexguy.com/?p=132</guid>
		<description><![CDATA[Here&#8217;s another gotcha that took me a while to realize what was wrong. I was using an ArrayCollection to hold a collection of items. I had a custom sort applied since the items were typed objects that needed to be sorted according to certain, out-of-the-ordinary fields. In the sort method, I was comparing values and [...]]]></description>
				<content:encoded><![CDATA[<p>Here&#8217;s another gotcha that took me a while to realize what was wrong.</p>
<p>I was using an ArrayCollection to hold a collection of items.  I had a custom sort applied since the items were typed objects that needed to be sorted according to certain, out-of-the-ordinary fields.  In the sort method, I was comparing values and returning either -1 or 1.</p>
<p><code>return itemA &gt; itemB ? -1 : 1;</code></p>
<p>From the docs for a compareFunction:</p>
<p style="padding-left: 30px;">The method used to compare items when sorting. If you specify this property, Flex ignores any <code>compareFunction</code> properties that you specify in the <code>ISortField</code> objects that you use in this class.</p>
<p style="padding-left: 30px;">The compare function must have the following signature:</p>
<pre style="padding-left: 30px;"><code>         function [name](a:Object, b:Object, fields:Array = null):int</code></pre>
<p style="padding-left: 30px;">This function must return the following value:</p>
<ul style="padding-left: 30px;">
<li>-1, if the <code>Object a</code> should appear before the <code>Object b</code> in the sorted sequence</li>
<li>0, if the <code>Object a</code> equals the <code>Object b</code></li>
<li>1, if the <code>Object a</code> should appear after the <code>Object b</code> in the sorted sequence</li>
</ul>
<p style="padding-left: 30px;">To return to the internal comparision function, set this value to <code>null</code>.</p>
<p>I decided that instead of returning 0 if they were the same, I would just let it stick it below the item. No big deal.</p>
<p>Later, when checking to see if an item was selected, I used the <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/collections/ListCollectionView.html#contains()">contains()</a> method to see if an item was in the ArrayCollection.  I quickly noticed that it wasn&#8217;t finding my item, even when I knew it was in the list.  Stepping through the code, and diving in to the Flex framework classes, I found that the contains() method uses the custom sort compare method to compare the item you&#8217;re looking for with the items in the list.  It determines it found the item when it gets 0 back from the compare function.  Since my custom compare method never returned 0, it never found the item.</p>
<p>Knowing this also helped me optimize the compare method for finding items.  Instead of thinking just in terms of whether one item goes before or after another item (or at the same level), I could also think about the comparisons in terms of checking to see if itemA <em>was </em>itemB.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.theflexguy.com/2011/05/24/arraycollection-uses-your-sort/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Don&#8217;t forget the down state</title>
		<link>http://www.theflexguy.com/2010/11/10/dont-forget-the-down-state/</link>
		<comments>http://www.theflexguy.com/2010/11/10/dont-forget-the-down-state/#comments</comments>
		<pubDate>Wed, 10 Nov 2010 00:23:21 +0000</pubDate>
		<dc:creator>marty</dc:creator>
				<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://www.theflexguy.com/?p=124</guid>
		<description><![CDATA[I have been immersed in Flex 4 lately and had this issue come up.  It seems like it might be fairly easy to run into and isn&#8217;t entirely obvious at first so I&#8217;ll share.  I had a custom component that included buttons that weren&#8217;t registering click events. Here&#8217;s the scenario.  I created a custom component [...]]]></description>
				<content:encoded><![CDATA[<p>I have been immersed in Flex 4 lately and had this issue come up.  It seems like it might be fairly easy to run into and isn&#8217;t entirely obvious at first so I&#8217;ll share.  I had a custom component that included buttons that weren&#8217;t registering click events.</p>
<p>Here&#8217;s the scenario.  I created a custom component that contained a background rectangle for highlighting, a label to display the name of the item, a toggle button for expanding the item and a button for editing the item.  I won&#8217;t get into the specifics of what this component is for, but just stick to the high level concept.</p>
<p>[ [expandBtn:ToggleButton] [labelDisplay:Label] [editBtn:Button] ]</p>
<p>The component had a number of states:</p>
<pre>[SkinState("up")]
[SkinState("over")]
[SkinState("down")]
[SkinState("upAndSelected")]
[SkinState("overAndSelected")]
[SkinState("downAndSelected")]</pre>
<p>This is similar to the ToggleButton component in the SDK but didn&#8217;t need the disabled state.  I created mouseEvent handlers to take the rollOver, rollOut, mouseDown, mouseUp and click events so I could handle them appropriately, setting properties for the getCurrentSkinState() method to use and setting invalidateSkinState() after changing the properties.</p>
<p>In the components up state, I wanted just the label to show and then when the user hovers over the component, the expand and edit buttons show.  Using states, this is simple enough to accomplish in the skin for the component:</p>
<pre>
<div id="_mcePaste">&lt;s:states&gt;
  &lt;s:State name="up" /&gt;
  &lt;s:State name="over" stateGroups="overStates" /&gt;
  &lt;s:State name="down" stateGroups="downStates" /&gt;
  &lt;s:State name="upAndSelected" stateGroups="selectedStates" /&gt;
  &lt;s:State name="overAndSelected" stateGroups="overStates, selectedStates" /&gt;
  &lt;s:State name="downAndSelected" stateGroups="downStates, selectedStates" /&gt;
&lt;/s:states&gt;
...</div>
<div id="_mcePaste">&lt;s:ToggleButton id="expandBtn" includeIn="overStates" .../&gt;
</div>
<div id="_mcePaste">&lt;s:Label id="labelDisplay" ... /&gt;
</div>
<div id="_mcePaste">&lt;s:Button id="editBtn" includeIn="overStates" .../&gt;</div></pre>
<p>The ellipses indicate additional code that is irrelevant.</p>
<p>I added the click handlers for the buttons in the custom component so I could capture the clicks and dispatch my own custom event.</p>
<p>So this starts out looking fine.  The buttons show up when the mouse is hovered.  Great.  I click on the edit button and&#8230; nothing.  The click handler is never called.  Do you see why?</p>
<p>Hint: Because events like clicks travel the displayList, the surrounding component will react to the clicks of the buttons inside it too.</p>
<p>Ok, here&#8217;s the chain of events:</p>
<ol>
<li>The user presses the mouse button down over the edit button.</li>
<li>The edit button gets the mouseDown and enters it&#8217;s down state (if it has one).</li>
<li>The surrounding component gets the mouseDown and changes it&#8217;s skin state to the down state.</li>
<li>The edit button is not included in the down state, so it is removed.</li>
<li>The user releases the mouse button.</li>
<li>The surrounding component gets the mouseUp and returns to the over state.</li>
<li>The edit button is included in the over state so it appears again.</li>
</ol>
<p>Since the edit button wasn&#8217;t included in the down state, it never had a chance to react to a click event.  Click events occur when the user presses and releases the mouse button over a component and the edit button was not around for that whole chain of events.</p>
<p>Solution: Add the buttons into the downStates so they exist during the entire click action.  Problem solved.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.theflexguy.com/2010/11/10/dont-forget-the-down-state/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AIR on Android</title>
		<link>http://www.theflexguy.com/2010/02/15/air-on-android/</link>
		<comments>http://www.theflexguy.com/2010/02/15/air-on-android/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 16:40:16 +0000</pubDate>
		<dc:creator>marty</dc:creator>
				<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Adobe has made the announcement that AIR developers will be able to create applications for Android in late 2010! &#160;This is exciting news for AIR developers, since it opens up the mobile devices arena. &#160;AIR 2.0 will have support for multi-touch gestures, GPS, accelerometer and screen layout. Check out the AIR team blog to see [...]]]></description>
				<content:encoded><![CDATA[<p>Adobe has made the <a href="http://www.adobe.com/aboutadobe/pressroom/pressreleases/201002/021510FlashPlayerMWC.html">announcement</a> that AIR developers will be able to create applications for Android in late 2010! &nbsp;This is exciting news for AIR developers, since it opens up the mobile devices arena. &nbsp;AIR 2.0 will have support for multi-touch gestures, GPS, accelerometer and screen layout.</p>
<p>Check out the <a href="http://blogs.adobe.com/air/2010/02/preview_of_air_on_android.html">AIR team blog</a> to see their post on the subject.</p>
<p>Personally, I got the Motorola Droid for Christmas, and have been loving it. &nbsp;I&#8217;m quite excited to have the opportunity to develop applications for my phone using technologies I already love and know so well.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.theflexguy.com/2010/02/15/air-on-android/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Year, Improved Site</title>
		<link>http://www.theflexguy.com/2010/01/05/new-year-improved-site/</link>
		<comments>http://www.theflexguy.com/2010/01/05/new-year-improved-site/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 00:57:03 +0000</pubDate>
		<dc:creator>adminwp</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[domain registration]]></category>
		<category><![CDATA[dreamhost]]></category>
		<category><![CDATA[hosting]]></category>
		<category><![CDATA[promo]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[It&#8217;s a new year and that means a great excuse to make some site improvements. I feel like theflexguy.com has been a moving target ever since it&#8217;s conception. I was originally hosting my site on GoDaddy. I was fairly pleased, although they gave me a dirty feeling (have you seen their commercials?). Here&#8217;s some of [...]]]></description>
				<content:encoded><![CDATA[<div>It&#8217;s a new year and that means a great excuse to make some site improvements. I feel like theflexguy.com has been a moving target ever since it&#8217;s conception. I was originally hosting my site on GoDaddy. I was fairly pleased, although they gave me a dirty feeling (have you seen their commercials?). Here&#8217;s some of the changes I made for the new year, and why.</div>
<div>
<ul>
<li><a href="http://www.dreamhost.com/r.cgi?474250"><img style="float: right; margin-left: 5px;" src="http://images.dreamhost.com/rewards/125x125-a.gif" alt="" /></a>Hosting is now with <a href="http://www.dreamhost.com/r.cgi?474250">DreamHost</a> &#8211; I have some friends who use <a href="http://www.dreamhost.com/r.cgi?474250">DreamHost</a> and were very pleased. I must say, after dealing with them for a while now, I am quite pleased too. Their customer service is outstanding, they are generous with hosting and bandwidth and it&#8217;s all so very easy to use. If you decide to check them out, you can use this promo code <span class="highlight"> <strong>THEFLEXGUY_PROMO</strong> </span> to get $30 off a year of hosting and a free domain registration, courtesy of me &#8211; you&#8217;re welcome.</li>
<li>Comment system is easier to use now &#8211; I have been struggling with commenting since I use Joomla, and it&#8217;s not designed out of the box to have comments. I&#8217;m now using JComments to provide a simple interface that doesn&#8217;t require any registration.</li>
<li>Pretty URLs &#8211; this is something I have wanted for a long time but never could get to work right on GoDaddy. I finally have it working on <a href="http://www.dreamhost.com/r.cgi?474250">DreamHost</a>. Hopefully, it&#8217;ll be a lot easier to link to blog posts since the urls are a little more meaningful.</li>
</ul>
<div>I&#8217;m hoping to continue to improve the site so that users in the blogosphere can use it easier.</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.theflexguy.com/2010/01/05/new-year-improved-site/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 1.175 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2013-05-22 02:18:35 -->
