<?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>Doug's Blog &#187; Coding</title>
	<atom:link href="http://blog.dougco.com/category/coding/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.dougco.com</link>
	<description>Handily dispensing information to .00000001% of the world's population</description>
	<lastBuildDate>Fri, 20 Aug 2010 00:20:40 +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>PHP not fully recognizing php.ini</title>
		<link>http://blog.dougco.com/coding/php-not-fully-recognizing-phpini/</link>
		<comments>http://blog.dougco.com/coding/php-not-fully-recognizing-phpini/#comments</comments>
		<pubDate>Sat, 03 Oct 2009 19:04:25 +0000</pubDate>
		<dc:creator>doug</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[500 error]]></category>
		<category><![CDATA[php.ini]]></category>
		<category><![CDATA[timeout]]></category>

		<guid isPermaLink="false">http://blog.dougco.com/coding/php-not-fully-recognizing-phpini/</guid>
		<description><![CDATA[OK, here&#8217;s an odd one I encountered on one of my older servers running Apache2 and PHP 5.2.5
I had php scripts failing and generating &#8220;500&#8243; errors on the browser because they were running too long, or sometimes because a large file was being uploaded. I spent time playing with php.ini variables, only to find out [...]]]></description>
			<content:encoded><![CDATA[<p>OK, here&#8217;s an odd one I encountered on one of my older servers running Apache2 and PHP 5.2.5</p>
<p>I had php scripts failing and generating &#8220;500&#8243; errors on the browser because they were running too long, or sometimes because a large file was being uploaded. I spent time playing with php.ini variables, only to find out that PHP wasn&#8217;t processing some of them!</p>
<p>Using phpinfo(), I noticed that the vars were not being set via php.ini, which I had set properly when it was compiled, ala:</p>
<p><span style="color: #339966;">&#8216;./configure &#8211;with-apxs2=/opt/apache2/bin/apxs &#8211;with-mysql=/opt/mysql &#8211;with-zlib &#8211;with-config-file-path=/etc/php.ini &#8211;with-curl=/usr/lib64 &#8211;with-pear=/usr/share/pear &#8211;libdir=lib64 &#8211;with-pdo-mysql &#8211;with-gettext &#8211;enable-bcmath &#8211;with-oci8=instantclient,/home/instantclient10_1&#8242; &#8216;&#8211;enable-sigchild &#8211;with-pdo-oci=instantclient,/home/instantclient10_1,10.1.0.5&#8242;</span></p>
<p>I didn&#8217;t want to risk affecting the system by re-installing PHP, so instead I found the workaround was to create a .htaccess file that contained:</p>
<p><span style="color: #339966;">php_value upload_max_filesize 8M<br />
php_value max_execution_time 600</span></p>
<p>and this did the trick! So hopefully that helps anyone who is running this version of php and encountered this problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dougco.com/coding/php-not-fully-recognizing-phpini/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Inline Poker Cards</title>
		<link>http://blog.dougco.com/coding/inline-poker-cards/</link>
		<comments>http://blog.dougco.com/coding/inline-poker-cards/#comments</comments>
		<pubDate>Fri, 11 Jul 2008 23:04:14 +0000</pubDate>
		<dc:creator>doug</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Poker]]></category>
		<category><![CDATA[cards]]></category>
		<category><![CDATA[poker blog]]></category>
		<category><![CDATA[wordpress plugin]]></category>

		<guid isPermaLink="false">http://blog.dougco.com/coding/inline-poker-cards/</guid>
		<description><![CDATA[I created a WordPress plugin to display small poker cards in blog posts. Once you install the plugin you can use the nomenclature of:
&#91;Ac&#93;
to show the card of Ace of Clubs for example. You use a two-letter code that is Rank and Suit to show a card. The ranks/suits are as follows:
Ranks:  2, 3, [...]]]></description>
			<content:encoded><![CDATA[<p>I created a WordPress plugin to display small poker cards in blog posts. Once you install the plugin you can use the nomenclature of:</p>
<p>&#91;Ac&#93;</p>
<p>to show the card of Ace of Clubs for example. You use a two-letter code that is Rank and Suit to show a card. The ranks/suits are as follows:</p>
<p>Ranks:  2, 3, 4, 5, 6, 7, 8, 9, T, J, Q, K, A</p>
<p>Suits: c, d, h, s, x</p>
<p>where c=Clubs, d=Diamonds, h=Hearts, s=Spades, and x=Unknown</p>
<p>So go ahead and tell people how you had your  <IMG SRC="/wp-content/plugins/inline_poker_cards/smallcards/Ad.gif" border="0" style="margin-bottom:-3px"> <IMG SRC="/wp-content/plugins/inline_poker_cards/smallcards/Ah.gif" border="0" style="margin-bottom:-3px"> cracked by a donkey with  <IMG SRC="/wp-content/plugins/inline_poker_cards/smallcards/5c.gif" border="0" style="margin-bottom:-3px"> <IMG SRC="/wp-content/plugins/inline_poker_cards/smallcards/8c.gif" border="0" style="margin-bottom:-3px"> !</p>
<p>Download the plugin <a href="/wp-content/uploads/inline_poker_cards.zip" title="Download the plugin">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dougco.com/coding/inline-poker-cards/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tips Using Amazon EC2</title>
		<link>http://blog.dougco.com/coding/tips-using-amazon-ec2/</link>
		<comments>http://blog.dougco.com/coding/tips-using-amazon-ec2/#comments</comments>
		<pubDate>Wed, 21 May 2008 21:08:57 +0000</pubDate>
		<dc:creator>doug</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[amazon ec2]]></category>
		<category><![CDATA[ec2 tips]]></category>

		<guid isPermaLink="false">http://blog.dougco.com/coding/tips-using-amazon-ec2/</guid>
		<description><![CDATA[When I started using Amazon&#8217;s EC2 service, I found it hard to gather all the info I needed. There was no easy guide that provided all the steps in an easy format. So, here are some tips I hope some might find helpful. I am interacting with EC2 from a Linux system, so my tips [...]]]></description>
			<content:encoded><![CDATA[<p>When I started using <a href="http://www.amazon.com/EC2-AWS-Service-Pricing/b/ref=sc_fe_l_2?ie=UTF8&amp;node=201590011&amp;no=3435361&amp;me=A36L942TSJ2AJA" target="_blank">Amazon&#8217;s EC2 service</a>, I found it hard to gather all the info I needed. There was no easy guide that provided all the steps in an easy format. So, here are some tips I hope some might find helpful. I am interacting with EC2 from a Linux system, so my tips are from that viewpoint.</p>
<p>I assume you have already done the basics, like <a href="http://aws-portal.amazon.com/gp/aws/developer/account/index.html?action=access-key" target="_blank">created your developer account</a> (and know your secret key), and <a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=351&amp;categoryID=88" target="_blank">installed the command line tools</a>.</p>
<p>Note that you will need <a href="http://java.sun.com/javase/downloads/index.jsp" target="_blank">Java</a> installed on your system for the tools to function.</p>
<p>You can find the official EC2 docs <a href="http://developer.amazonwebservices.com/connect/kbcategory.jspa?categoryID=87" target="_blank">here.</a></p>
<p>Now, on to my tips!</p>
<h3><strong>Find A Starter Image</strong></h3>
<p>You can browse the images at Amazon via the command :</p>
<address><span style="color: #008000;">% ec2-describe-images</span> </address>
<p>You&#8217;ll see a bunch of images that are out there, in different UNIX flavors, and some with LAMP already installed. I found that whatever you pick, you&#8217;ll want to do your own package installs anyway, so just pick a baseline that you like, i.e. Ubuntu or Redhat or whichever you feel comfortable.</p>
<p>Note that you need the AMI string of your choice to continue. Not only will you see a number of Amazon created AMI&#8217;s, but other folks have created some public AMIs that you can choose from. Here are some <a href="http://alestic.com/" target="_blank">AMIs for Ubuntu</a> you can check out.</p>
<h3>Choose A Server Size</h3>
<p>Note that EC2 provides a small, large, and extra-large version your can use. I&#8217;ve found that the small instances are incompatible with the the large and XL, so be careful! You should start with the large if you plan on any expansion whatsoever.</p>
<p>So when you are ready to create an instance, you&#8217;ll need to specify the size (m1.large or m1.xlarge) on the command line otherwise it will default to small, i.e.:</p>
<address><span style="color: #008000;">% ec2-run-instances ami-20b65349 -k gsg-keypair -t m1.large</span></address>
<p>You&#8217;ll need to create a gsg-keypair file first of course. This is described nicely in the command line docs, you&#8217;ll use &#8220;ec2-create-keypair&#8221;.</p>
<p>Note that you can apply a firewall to your instance via the &#8220;-g &lt;name&gt;&#8221; option, where you define a group with the name of &#8220;&lt;name&gt;&#8221;. You can see what groups you have via:</p>
<address><span style="color: #008000;">%  ec2-describe-group</span></address>
<p>You can create these groups using commands like:</p>
<address><span style="color: #008000;">%  ec2-authorize mygroup -P tcp -p 22 -s 0.0.0.0/0</span></address>
<blockquote></blockquote>
<h3>Access Your Instance</h3>
<p>After you run an instance, you can check on the progress via:</p>
<address><span style="color: #008000;">%  ec2-describe-instances</span></address>
<p>And you can provide the instance name also, e.g.</p>
<address><span style="color: #008000;">%  ec2-describe-instances i-be9237aaa</span></address>
<p>Then you can SSH into it when it is ready by using the domain name it returns, e.g.</p>
<address><span style="color: #008000;">%  ssh -i gsg-keypair root@ec2-67-200-1-123.z-1.compute-1.amazonaws.com</span></address>
<blockquote></blockquote>
<h3>Customize Your Instance</h3>
<p>You should now make sure your instance has all the packages you want, and configure them how you like. I install the latest Apache, MySQL, PHP, Perl, etc, and edit all the configuration files to my liking.fone</p>
<p>Make sure you stay in &#8220;/&#8221;, and do not use &#8220;/mnt&#8221; since this will go away if you reboot and won&#8217;t be saved when you save your instance.</p>
<p>If you need more space, you can use the extra storage service from Amazon although I have not done that at this point.</p>
<p>When you have everything the way you like it, you should save your instance. You will use <a href="http://docs.amazonwebservices.com/AWSEC2/2008-02-01/DeveloperGuide/CLTRG-ami-bundle-vol.html" target="_blank">ec2-bundle-vol</a> to create the image, and <a href="http://docs.amazonwebservices.com/AWSEC2/2008-02-01/DeveloperGuide/CLTRG-ami-upload-bundle.html" target="_blank">ec2-upload-bundle</a> to upload it to Amazon&#8217;s storage service.</p>
<p>You&#8217;ll need your secret key, access key, cert key, user id and a sample command set is as follows. You will run these from your Amazon instance (where real keys and numbers are replaced by X&#8217;s and fake numbers):</p>
<address><span style="color: #008000;">amazon%  ec2-bundle-vol  -d /mnt -k pk-XXXXXXX.pem -c cert-XXXXXXX.pem -u 432132132132 -s 1536</span></address>
<address> </address>
<address> </address>
<address><span style="color: #008000;">amazon%   ec2-upload-bundle -b my_image_name -m /mnt/image.manifest.xml -a XXXXXXX -s XXXXXX</span></address>
<p>Once it is uploaded, you will need to now register it as an AMI image you can access later. You need to do this command from your local host:</p>
<address><span style="color: #008000;">%  ec2-register my_image_name/image.manifest.xml</span></address>
<p>This will output your AMI string that you need to note so you can use it later to use your new instance on new Amazon servers.</p>
<h3>Cleanup When Done</h3>
<p>Don&#8217;t forget to make sure you terminate instances you don&#8217;t need to use anymore, or you will continue to be charged for them! Run &#8220;ec2-describe-instances&#8221; to see what you are running, and then you can use &#8220;ec2-terminate-instances&#8221; with the instance string as an argument to remove them.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dougco.com/coding/tips-using-amazon-ec2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Passing State with a Timer</title>
		<link>http://blog.dougco.com/coding/flex/passing-state-with-a-timer/</link>
		<comments>http://blog.dougco.com/coding/flex/passing-state-with-a-timer/#comments</comments>
		<pubDate>Tue, 22 Apr 2008 00:23:05 +0000</pubDate>
		<dc:creator>doug</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[timer event]]></category>

		<guid isPermaLink="false">http://blog.dougco.com/coding/flex/passing-state-with-a-timer/</guid>
		<description><![CDATA[Early on in my Flex work I found many cases where I needed the function after a timer event to have some more information. In other words, I really needed to pass state of variables to the next function. You could do this by using global variables, but a cleaner way is to create a [...]]]></description>
			<content:encoded><![CDATA[<p>Early on in my Flex work I found many cases where I needed the function after a timer event to have some more information. In other words, I really needed to pass state of variables to the next function. You could do this by using global variables, but a cleaner way is to create a subclass of the Timer class and pass along an object.</p>
<p>To do this, you can create this actionscript class in your main mxml directory (or get fancy and name it within subdirectories) as &#8221; ObjTimer.as&#8221; and the contents are simply:</p>
<pre>
// ActionScript file
// ObjTimer is just a timer that can hold an object of variables to pass along
package {
    import flash.utils.Timer;
    public class ObjTimer extends Timer {
        public var obj:Object = new Object;
        public function ObjTimer(delay:Number, repeatCount:int = 0) {
             super(delay, repeatCount);
        }
    }
}</pre>
<p>and then you can access it from within your mxml like so for example:</p>
<pre>
var newTimer: ObjTimer = new ObjTimer(900,1);
newTimer.obj["myvar1"] = "test";
newTimer.obj["firstname"] = "joe";
newTimer.obj["count"] = 10;
newTimer.addEventListener(TimerEvent.TIMER, handleFunction);
newTimer.start();

private function handleFunction(e:Event):void{
    var value:String = e.target.obj["myvar1"];
    var fn:String = e.target.obj["firstname"];
    var count:int = parseInt(e.target.obj["count"]);
}</pre>
<p>This example is really quick-n-dirty, you can make it nicer by adding setters and getters in the new class, but for an easy implementation this should get you going.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dougco.com/coding/flex/passing-state-with-a-timer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FaceBook Applications</title>
		<link>http://blog.dougco.com/coding/facebook/facebook-applications/</link>
		<comments>http://blog.dougco.com/coding/facebook/facebook-applications/#comments</comments>
		<pubDate>Tue, 25 Mar 2008 22:46:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[FaceBook]]></category>

		<guid isPermaLink="false">http://blog.dougco.com/coding/facebook/facebook-applications/</guid>
		<description><![CDATA[I&#8217;ve been developing some applications on FaceBook and like what they&#8217;ve built as their API framework. It&#8217;s a work in progress, but is growing and getting better. My FaceBook profile is here, and I&#8217;ve built the following applications so far:
 Ujogo Poker: This is a more condensed version of the official Ujogo.com website, and allows [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been developing some applications on FaceBook and like what they&#8217;ve built as their API framework. It&#8217;s a work in progress, but is growing and getting better. My FaceBook profile is <a href="http://www.facebook.com/profile.php?id=748092525" target="_blank">here,</a> and I&#8217;ve built the following applications so far:</p>
<p><a href="http://apps.facebook.com/ujogopoker" target="_blank"><img class="alignleft" style="margin-left: 8px; margin-right: 8px;" src="http://photos-f.ak.facebook.com/photos-ak-sctm/v43/221/7218169277/app_1_7218169277_3716.gif" alt="" width="75" height="75" align="left" /> Ujogo Poker</a>: This is a more condensed version of the official <a href="http://www.ujogo.com" target="_blank">Ujogo.com</a> website, and allows the FB avatars to be shown, adding friends, seeing user&#8217;s profiles inside the app, and various alerts to users based on performance, etc. The backend code is done in J2EE using the Java API.<br clear=left><br />
<a href="http://apps.facebook.com/forgiveness" target="_blank"><img class="alignleft" style="margin-left: 8px; margin-right: 8px;" src="http://photos-b.ak.facebook.com/photos-ak-sctm/v43/245/5103502985/app_1_5103502985_1788.gif" alt="" width="75" height="75" align="left" />Confessions:</a> This is a game to let users create confessions that are put in front of their group of friends for judgement. The backend is done in PHP using the FaceBook PHP API.<br clear=left><br />
<a href="http://apps.facebook.com/drivertest" target="_blank"><img class="alignleft" style="margin-left: 8px; margin-right: 8px;" src="http://photos-h.ak.facebook.com/photos-ak-sctm/v43/19/11324052703/app_1_11324052703_6976.gif" alt="" width="75" height="75" align="left" />The Driving Test</a>: A test-taking game where you can add your own questions into the database. The backend is in PHP. It is a good thing I have an approval process function for when people submit their own questions, some of the stuff people submit is crazy! Perhaps I&#8217;ll post some of it someday.<br clear=left></p>
<p>All the applications are Flash (SWF) developed in Flex, communicating with standard backend services.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dougco.com/coding/facebook/facebook-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DataGrid with Multiple Pulldowns</title>
		<link>http://blog.dougco.com/coding/flex/datagrid-with-multiple-pulldowns/</link>
		<comments>http://blog.dougco.com/coding/flex/datagrid-with-multiple-pulldowns/#comments</comments>
		<pubDate>Mon, 24 Mar 2008 22:38:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://blog.dougco.com/coding/flex/datagrid-with-multiple-pulldowns/</guid>
		<description><![CDATA[Here is an example that illustrates how you need to add some additional logic when you add ItemRenderers into a DataGrid. The way I came across this problem is I noticed that when I had ItemRenderers doing things like checkboxes or pulldowns, the choices that they were set to on a row basis would CHANGE [...]]]></description>
			<content:encoded><![CDATA[<p>Here is an example that illustrates how you need to add some additional logic when you add ItemRenderers into a DataGrid. The way I came across this problem is I noticed that when I had ItemRenderers doing things like checkboxes or pulldowns, the choices that they were set to on a row basis would CHANGE whenever I scrolled or sorted a column.</p>
<p>I struggled with finding a way, as I talk about in another posting, and found that using the dataChange event does the trick, and I always create the ItemRenderer as a separate component instead of trying to put all the logic in the main mxml. The component gets the initial setting of the value for that cell via &#8220;.data&#8221; and then you need to maintain and check it within the component. This can end up with the coder doing some hacking, and my example is only that &#8212; an example. I&#8217;m sure there are more elegant ways to achieve this. But that&#8217;s one of the things I think Flex shares with Perl &#8212; there are always multiple ways to get something done!</p>
<p>Take a look at the first flash example, where I DON&#8217;T use the dataChange &#8212; then see how it works nicely on the 2nd example.</p>
<p>First example (Try sorting columns and see it randomizes each time):</p>
<p id="swf5e44_4" style="text-align: center"> This movie requires Adobe Flash Player &#8212; Download at www.adobe.com</p>
<p><script type="text/javascript"> var vswf1 = new SWFObject("/wp-content/uploads/flash/test_datagrid1.swf", "id4", "400", "200", "9", "#CCCCCC"); vswf1.addParam("wmode", "transparent"); vswf1.addParam("menu", "false"); vswf1.addParam("quality", "high"); vswf1.write("swf5e44_4"); </script></p>
<p>Second example (Works!):</p>
<p id="swf5e44_8" style="text-align: center"> This movie requires Adobe Flash Player &#8212; Download at www.adobe.com</p>
<p><script type="text/javascript"> var vswf2 = new SWFObject("/wp-content/uploads/flash/test_datagrid2.swf", "id8", "400", "200", "9", "#CCCCCC"); vswf2.addParam("wmode", "transparent"); vswf2.addParam("menu", "false"); vswf2.addParam("quality", "high"); vswf2.write("swf5e44_8"); </script></p>
<p>Download my code sample <a href="/wp-content/uploads/flash/test_datagrid.zip">here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dougco.com/coding/flex/datagrid-with-multiple-pulldowns/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex2 -&gt; Flex3 font size issue</title>
		<link>http://blog.dougco.com/coding/flex/flex2-flex3-font-size-issue/</link>
		<comments>http://blog.dougco.com/coding/flex/flex2-flex3-font-size-issue/#comments</comments>
		<pubDate>Fri, 21 Mar 2008 17:23:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://blog.dougco.com/coding/flex/flex2-flex3-font-size-issue/</guid>
		<description><![CDATA[I switched to Flex3 the other day and found that the font sizing for the default font has changed! So on most of my applications where I
painstakingly sized buttons so that they exactly fit the text label, I now see the text does NOT FIT anymore and has &#8220;&#8230;&#8221; at the end!
The Flex folks have [...]]]></description>
			<content:encoded><![CDATA[<p><font face="Times New Roman" size="3"><span style="font-size: 12pt">I switched to Flex3 the other day and found that the font sizing for the default font has changed! So on most of my applications where I<br />
painstakingly sized buttons so that they exactly fit the text label, I now see the text does NOT FIT anymore and has &#8220;&#8230;&#8221; at the end!</span></font></p>
<p>The Flex folks have some good solutions, see more on <a href="http://tech.groups.yahoo.com/group/flexcoders/message/107044" target="_blank">Flexcoders.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dougco.com/coding/flex/flex2-flex3-font-size-issue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Doesn&#8217;t seem like normal behaviour for DataGrid!</title>
		<link>http://blog.dougco.com/coding/flex/doesnt-seem-like-normal-behaviour-for-datagrid/</link>
		<comments>http://blog.dougco.com/coding/flex/doesnt-seem-like-normal-behaviour-for-datagrid/#comments</comments>
		<pubDate>Fri, 21 Mar 2008 17:10:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://blog.dougco.com/coding/flex/doesnt-seem-like-normal-behaviour-for-datagrid/</guid>
		<description><![CDATA[I ran into a problem the other day trying to create a DataGrid that had voting buttons as an itemRenderer. When an action was taken in that cell, the buttons would change, i.e., gray out or light up to show a click occurred. The problem that would happen is that, when I scrolled the list [...]]]></description>
			<content:encoded><![CDATA[<p>I ran into a problem the other day trying to create a DataGrid that had voting buttons as an itemRenderer. When an action was taken in that cell, the buttons would change, i.e., gray out or light up to show a click occurred. The problem that would happen is that, when I scrolled the list up or down, that column would randomize!</p>
<p>I found posts that talked about solutions for very simple things like a checkbox in a column that did not have any elaborate actionscript behind it, but not to address a component that sat behind the itemRenderer. I figured it out though, and the answer is pretty simple.</p>
<p>I had to add a dataChange function call in the component&#8217;s main tag so it would force the cell to rethink it&#8217;s status when the grid would scroll.</p>
<p>The main mxml:</p>
<pre>&lt;mx:DataGrid id="userGrid" dataProvider="{userData}" sortableColumns="true"
    draggableColumns="false" width="100%" height="100%"&gt;
  &lt;mx:columns&gt;
    &lt;mx:DataGridColumn dataField="Topic" width="100" /&gt;
    &lt;mx:DataGridColumn id="votecol" dataField="status" headerText="Vote" sortable="true"
        itemRenderer="castVote" width="120" /&gt;
    &lt;/mx:columns&gt;
&lt;/mx:DataGrid&gt;</pre>
<p>The castVote component:</p>
<pre>&lt;mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" dataChange="gridMoved()"
    width="100%" height="100%"&gt;
&lt;mx:Script&gt;
        &lt;![CDATA[
        import mx.core.Application;
        import mx.events.ListEvent;

        private var myStatus:int = 0;

        private function gridMoved():void{
                if (data != null) {
                        myStatus=data.status;
                }
                doShow(myStatus);
        }

        private function doShow(n:int):void {
                // 0 means already voted, 1 is for, 2 is against
                if (n==0) {
                        buttons.visible=true;
                        v1.visible = v2.visible = false;
                        return;
                }else if (n==1) {
                        v1.visible=true; v2.visible=false;
                        myStatus = n;
                        buttons.visible=false;
                }else if (n==2) {
                        v2.visible=true; v1.visible=false;
                        myStatus = n;
                        buttons.visible=false;
                }
        }

        private function doClick(n:int):void {
                data.status = myStatus = n;
                doShow(n);
        }

        ]]&gt;
&lt;/mx:Script&gt;

        &lt;mx:Label id="v1" text="You voted FOR this resolution" visible="false" /&gt;
        &lt;mx:Label id="v2" text="You voted AGAINST this resolution!" visible="false" /&gt;
        &lt;mx:HBox id="buttons"&gt;
                &lt;mx:Button label="YES" click="doClick(1);" /&gt;
                &lt;mx:Button label="NO" click="doClick(2);" /&gt;
        &lt;/mx:HBox&gt;

&lt;/mx:Canvas&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.dougco.com/coding/flex/doesnt-seem-like-normal-behaviour-for-datagrid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
