<?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; Flex</title>
	<atom:link href="http://blog.dougco.com/category/coding/flex/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>Mon, 28 Nov 2011 18:22:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<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>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 [...]]]></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>

