<?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>carry the zero</title>
	<atom:link href="http://carrythezero.net/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://carrythezero.net/blog</link>
	<description>No, Walter, it did not look like Larry was about to crack.</description>
	<lastBuildDate>Fri, 30 Jul 2010 14:57:13 +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>Flex: Fixing truncated labels on the Tab Navigator</title>
		<link>http://carrythezero.net/blog/2010/07/30/flex-fixing-truncated-labels-on-the-tab-navigator/</link>
		<comments>http://carrythezero.net/blog/2010/07/30/flex-fixing-truncated-labels-on-the-tab-navigator/#comments</comments>
		<pubDate>Fri, 30 Jul 2010 13:49:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://carrythezero.net/blog/?p=425</guid>
		<description><![CDATA[If you have ever had the pleasure of working with both the Tab Navigator and the PopUpManager, you may have come across this lovely issue.  Basically, when you have a Tab Navigator in a PopUp, the Label on the FIRST tab gets truncated when the PopUp is first launched.  After you hover over [...]]]></description>
			<content:encoded><![CDATA[<p>If you have ever had the pleasure of working with <em>both</em> the <a href="http://livedocs.adobe.com/flex/3/langref/mx/containers/TabNavigator.html">Tab Navigator</a> and the <a href="http://livedocs.adobe.com/flex/3/langref/mx/managers/PopUpManager.html">PopUpManager</a>, you may have come across this lovely issue.  Basically, when you have a Tab Navigator in a PopUp, the Label on the FIRST tab gets truncated when the PopUp is first launched.  After you hover over the tab, the label is fixed.  The best part is that when you hover over the tab, it doesn&#8217;t actually change its width &#8211; it&#8217;s quite frustrating.</p>
<p>Looking for solutions on the interwebz reveals a few gems, but none that I like &#8211; mainly because they involve hard-coding widths.  After some minor digging around the Tab Navigator source and doing a few experiments, I found a solution of my own.</p>
<p>Its quite simple actually:</p>
<ol>
<li>The Tab Navigator is made up of several UIComponents in the standard Flex SDK.  The actual tab that the user clicks is simply a Button.</li>
<li>The Tab Navigator has a getTabAt() method, which returns a Button object.</li>
<li>A Button, being a sub class of UIComponent, has the invalidateDisplayList() method.  Calling this will<br />
<blockquote><p>Mark a component so that its updateDisplayList() method gets called during a later screen update.</p></blockquote>
</li>
</ol>
<p>Put the above steps together and you can create a custom Tab Navigator that calls invalidateDisplayList() on it&#8217;s first Tab after the CREATION_COMPLETE event is fired.  See below for the simple code&#8230;</p>
<pre class="brush: jscript;">
package foo
{
	import mx.containers.TabNavigator;
	import mx.events.FlexEvent;

	public class SweetTabNavigator extends TabNavigator
	{
		public function SweetTabNavigator()
		{
			super();
		    this.addEventListener(FlexEvent.CREATION_COMPLETE,
                            this.onCreationComplete);
		}

		protected function onCreationComplete(event:FlexEvent):void
		{
			this.getTabAt(0).invalidateDisplayList();
		}
	}
}
</pre>
<p>If you use this logic in your app, please extend Tab Navigator as seen above&#8230; Don&#8217;t go bloating your code with event handlers in the parent window, adding code inline in your MXML, etc&#8230;</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://carrythezero.net/blog/2010/07/30/flex-fixing-truncated-labels-on-the-tab-navigator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex: Log to the Firebug Console</title>
		<link>http://carrythezero.net/blog/2010/02/17/flex-simple-logging-to-the-firebug-console/</link>
		<comments>http://carrythezero.net/blog/2010/02/17/flex-simple-logging-to-the-firebug-console/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 22:28:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://carrythezero.net/blog/?p=417</guid>
		<description><![CDATA[Logging to the firebug console from a Flex App is easy.  A quick google search turns up loads of goodies&#8230; but you don&#8217;t really need a full fledged logging API for simple Flex Apps.  Additionally, the example in the Adobe Flex Cookbook pisses off Internet Explorer as there is no check to see [...]]]></description>
			<content:encoded><![CDATA[<p>Logging to the firebug console from a Flex App is easy.  A quick google <a href="http://www.google.com/search?hl=en&#038;q=flex+log+to+firebug&#038;aq=f&#038;aqi=&#038;oq=">search</a> turns up loads of goodies&#8230; but you don&#8217;t really need a full fledged logging API for simple Flex Apps.  Additionally, the example in the Adobe Flex Cookbook pisses off Internet Explorer as there is no check to see if <code>window.console</code> is even available.</p>
<p>At any rate, I wrote a small static class for logging to firebug from a Flex app.  Use it however you wish:</p>
<pre class="brush: jscript;">
package ctz.util
{
	import flash.external.ExternalInterface;

	public final class ConsoleLog
	{
		public function ConsoleLog()
		{
			throw new Error(&quot;static methods only&quot;);
		}

		public static function log(o:Object):void
		{
			if (o is Array)
				ConsoleLog.logArray(o as Array);
			else if (o is String)
				ConsoleLog.logString(o as String);
			else
				ConsoleLog.logObject(o);
		}

		public static function logString(msg:String):void
		{
			if (ExternalInterface.available)
				ExternalInterface.call(&quot;function log(msg){ if (window.console) { console.log(msg); } }&quot;, msg);
		}

		public static function logObject(obj:Object):void
		{
			var s:String = &quot;&quot;;
			for (var k:String in obj)
				s += k + &quot;: &quot; + obj[k];
			ConsoleLog.logString(s);
		}

		public static function logArray(arr:Array):void
		{
			var s:String = &quot;Item Count: &quot; + arr.length + &quot; || &quot;;
			for (var i:int = 0; i &lt; arr.length; i++)
				s += i + &quot;: &quot; + arr[i] + &quot; &quot;;
			ConsoleLog.logString(s);
		}
	}
}
</pre>
<p>File can be downloaded <a href="http://www.carrythezero.net/software/flex/ConsoleLog.as">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://carrythezero.net/blog/2010/02/17/flex-simple-logging-to-the-firebug-console/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex: Pump out DisplayObjects with the quickness.</title>
		<link>http://carrythezero.net/blog/2010/02/04/flex-pump-out-displayobjects-with-the-quickness/</link>
		<comments>http://carrythezero.net/blog/2010/02/04/flex-pump-out-displayobjects-with-the-quickness/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 22:21:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://carrythezero.net/blog/?p=387</guid>
		<description><![CDATA[Accomplishing a programming task with as few lines of code as possible is typically a good thing.  At the same time, keeping the readability of your code at a reasonable level is also a good thing &#8211; especially if other developers will be maintaining your code in the future.
When writing custom components in Flex [...]]]></description>
			<content:encoded><![CDATA[<p>Accomplishing a programming task with as few lines of code as possible is typically a good thing.  At the same time, keeping the <a href="http://en.wikipedia.org/wiki/Readability#In_computer_programming">readability</a> of your code at a reasonable level is also a good thing &#8211; <em>especially</em> if other developers will be maintaining your code in the future.</p>
<p>When writing <a href="http://carrythezero.net/blog/2009/06/02/flex-a-date-time-component/">custom components</a> in Flex (and more or less writing anything to do with DisplayObjects in Flex) you find yourself writing a lot of the same, boring code.  Basically, you instantiate a new <a href="http://livedocs.adobe.com/flex/3/langref/flash/display/DisplayObject.html">DisplayObject</a>, set some common properties on it, and then add it to a container.  For example, take the following piece of code:</p>
<pre class="brush: jscript;">
private function createUI():void
{
    var vbox:VBox = new VBox();
    vbox.percentWidth = 100;
    vbox.percentHeight = 100;
    vbox.name = 'My name is vbox';

    var txt:TextInput = new TextInput();
    txt.text = 'I am a TextInput';
    txt.setStyle('borderStyle', 'solid');
    txt.setStyle('borderThickness', 1);

    vbox.addChild(txt);
}
</pre>
<p>Pretty boring stuff, right?</p>
<p>Enter ctz.util.FlexUtils.  With FlexUtils, you can cut down on writing all that boring code &#8211; like the snippet above.  While there is nothing too complex or ground-breaking in this class, I find it to be quite helpful&#8230; and you may too:</p>
<pre class="brush: jscript;">
package ctz.util
{
	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	import flash.utils.*;

	import mx.collections.ArrayCollection;

	public final class FlexUtils
	{
		public function FlexUtils()
		{
			throw new Error('static methods only');
		}

		/**
		 * Create a Display Object and add some atts
		 */
		public static function createDisplayObject(typeName:Class, atts:Object=null):DisplayObject
		{
			try {
				var o:DisplayObject = new typeName();
				if (atts != null) {
					for (var k:String in atts) {
						if (o.hasOwnProperty(k)) {
							o[k] = atts[k];
						} else {
							typeName(o).setStyle(k, atts[k]);
						}
					}
				}
			} catch (e:Error) {
				trace('Error in FlexUtils.createDisplayObject: ' + e.message);
			}
			return o;
		}

		/**
		 * Given a root display object, get all children of the same type, recursively
		 */
		public static function getChildrenByType(collection:ArrayCollection, typeName:Class, rootObject:DisplayObjectContainer):void
		{
			var dobj:DisplayObject;
			for (var i:int = 0; i &lt; rootObject.numChildren; i++) {
				dobj = rootObject.getChildAt(i);
				if (dobj is typeName)
					collection.addItem(dobj);
				if (dobj is DisplayObjectContainer)
					FlexUtils.getChildrenByType(collection, typeName, dobj as DisplayObjectContainer);
			}
		}

		public static function objDump(o:Object):String
		{
			var s:String = '';
			for (var key:String in o)
				s += key + ' =&gt; ' + o[key] + '\n';
			return s;
		}
	}
}
</pre>
<p><em>Note, I should probably update the two custom components I have published to use this class, but I really don&#8217;t have the time these days.</em></p>
<p>The <strong>createUI()</strong> method from the snippet above is magically transformed into the snippet below using FlexUtils.createDisplayObject()&#8230;</p>
<pre class="brush: jscript;">
private function createUI():void
{
    var atts:Object = {percentWidth: 100, percentHeight: 100, name: 'My name is vbox'};
    var vbox:VBox = FlexUtils.createDisplayObject(VBox, atts) as VBox;

    atts = {text: 'I am a TextInput', borderStyle: 'solid', borderThickness: 1};
    var txt:TextInput = FlexUtils.createDisplayObject(TextInput, atts) as TextInput;

    vbox.addChild(txt);
}
</pre>
<p>I hope someone finds this remotely useful.</p>
<p>You can download the file <a href="http://www.carrythezero.net/software/flex/FlexUtils.as">here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://carrythezero.net/blog/2010/02/04/flex-pump-out-displayobjects-with-the-quickness/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Events, Javascript Classes, and &#8216;this.XYZ is not a function&#8217;</title>
		<link>http://carrythezero.net/blog/2009/08/05/jquery-events-javascript-classes-and-this-xyz-is-not-a-function/</link>
		<comments>http://carrythezero.net/blog/2009/08/05/jquery-events-javascript-classes-and-this-xyz-is-not-a-function/#comments</comments>
		<pubDate>Wed, 05 Aug 2009 22:51:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://carrythezero.net/blog/?p=353</guid>
		<description><![CDATA[If you are not a seasoned Javascript developer (like myself), and you start writing Javascript classes which include jQuery event bindings, you may become stumped on the issue I am about to describe.  On the contrary you are most likely more intelligent than I and realize that what you are trying to do is [...]]]></description>
			<content:encoded><![CDATA[<p>If you are not a seasoned Javascript developer (like myself), and you start writing Javascript classes which include jQuery event bindings, you <em>may</em> become stumped on the issue I am about to describe.  On the contrary you are most likely more intelligent than I and realize that what you are trying to do is wrong and you consult the jQuery documentation to find the answer within the first 2 minutes of stumbling upon this problem.</p>
<p>Anyways, the issue at hand is setting up event bindings via jQuery inside of a class.  This is easier explained with a simple code example.  Take the following class:</p>
<pre class="brush: jscript;">
function Page()
{
	var msg  = 'weeeeeeee';

	this.bindElements = function(elementOne, elementTwo)
	{
		$(elementOne).click(function() {
			this.elementOneStuff('yoyo');
		});
		$(elementTwo).click(this.elementTwoStuff);
	}

	this.elementOneStuff = function(a)
	{
		alert(a);
	}

	this.elementTwoStuff = function()
	{
		alert(this.msg);
	}
}

var p = new Page();
p.bindElements('#btnOne', '#btnTwo');
</pre>
<p>When you instantiate a new Page object and invoke the bindElements method you get barked at:</p>
<p><strong>this.elementOneStuff() is not a function.</strong></p>
<p>My initial reaction was that it was a scoping issue with my <a href="http://javascript.crockford.com/private.html">privileged</a> class methods.  After changing the architecture of my class to use public methods the same issue was there.</p>
<p><strong>Solution / Answer</strong></p>
<p>The <strong>this</strong> keyword that is being used in both of the callbacks will refer to the DOM element that dispatched the event&#8230;. <em>not an instance of the Page Class</em>.  This is in fact the correct behavior as it will almost always be what is desired.</p>
<p>jQuery.bind( type, [data], fn ) to the rescue!  Straight from the jQuery documentation:<br />
<strong><br />
data (Optional)	Object<br />
Additional data passed to the event handler as event.data<br />
</strong></p>
<p>We can simply pass an object as the data parameter to the bind method and then invoke our class methods through event.data.  So the updated, correct code would be: </p>
<pre class="brush: jscript;">
function Page()
{
	var msg  = 'weeeeeeee';

	this.bindElements = function(elementOne, elementTwo)
	{
		$(elementOne).bind('click', this, function(evt) {
			evt.data.elementOneStuff('yoyo');
		});
		$(elementTwo).bind('click', this, function(evt) {
			evt.data.elementTwoStuff();
		});
	}

	this.elementOneStuff = function(a)
	{
		alert(a);
	}

	this.elementTwoStuff = function()
	{
		alert(this.msg);
	}
}
</pre>
<p>This took me more time to figure out than I would like to admit.  I am posting this in the hopes that it saves someone some time and frustration.</p>
]]></content:encoded>
			<wfw:commentRss>http://carrythezero.net/blog/2009/08/05/jquery-events-javascript-classes-and-this-xyz-is-not-a-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex: A Date / Time Component</title>
		<link>http://carrythezero.net/blog/2009/06/02/flex-a-date-time-component/</link>
		<comments>http://carrythezero.net/blog/2009/06/02/flex-a-date-time-component/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 03:06:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[mxml]]></category>

		<guid isPermaLink="false">http://carrythezero.net/blog/?p=233</guid>
		<description><![CDATA[Edit: This project is now on github: git://github.com/danjarvis/DateTimeChooser.git
The Flex UIComponents for Dates, namely DateField and DateChooser let you easily collect date information from the users of your application(s).  However, and I&#8217;m not exactly sure why, but these components lack an interface for choosing time.  The application I&#8217;m currently working on deals heavily with [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Edit:</strong> This project is now on github: <strong>git://github.com/danjarvis/DateTimeChooser.git</strong></p>
<p>The Flex UIComponents for Dates, namely <a href="http://livedocs.adobe.com/flex/3/langref/mx/controls/DateField.html">DateField</a> and <a href="http://livedocs.adobe.com/flex/3/langref/mx/controls/DateChooser.html">DateChooser</a> let you easily collect date information from the users of your application(s).  However, and I&#8217;m not exactly sure why, but these components lack an interface for choosing time.  The application I&#8217;m currently working on deals heavily with Date/Time &#8211; thus this was a major issue for me.</p>
<p>A quick search on Google returns a bunch of custom components which solve the issue of choosing Date/Time in Flex.  While a few of the components I found would have been fine for my use I decided to roll my own, mainly for educational purposes.  </p>
<p>This component can be customized in several different ways.  Additionally, all of the children (e.g. NumericSteppers) are exposed so that styles can be applied.  Let me know if you have any questions on some of the properties as I am only showing the basics here.  </p>
<div align="center">
<br/><br />

<object width="500" height="250">
<param name="movie" value="http://www.carrythezero.net/software/flex/DateTimeChooser/DateTimeChooser.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<embed type="application/x-shockwave-flash" width="500" height="250" src="http://www.carrythezero.net/software/flex/DateTimeChooser/DateTimeChooser.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" ></embed>
</object>
<br />
<br/>
</div>
<p>Source can be downloaded <a href="http://www.carrythezero.net/software/flex/DateTimeChooser/srcview/DateTimeChooser.zip">here.</a></p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://carrythezero.net/blog/2009/06/02/flex-a-date-time-component/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Flex: Rounding Specific Corners on a Box.</title>
		<link>http://carrythezero.net/blog/2009/06/01/flex-rounding-specific-corners-on-a-box/</link>
		<comments>http://carrythezero.net/blog/2009/06/01/flex-rounding-specific-corners-on-a-box/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 04:51:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[mxml]]></category>

		<guid isPermaLink="false">http://carrythezero.net/blog/?p=270</guid>
		<description><![CDATA[Most of the Flex Containers have the cornerRadius attribute.  This is a lovely attribute which allows you to round the corners of layout objects.  Better yet, the Panel and TitleWindow components let you round the just top corners &#8211; YAY!  So&#8230; why the HELL didn&#8217;t Adobe implement the rounding of SPECIFIC corners [...]]]></description>
			<content:encoded><![CDATA[<p>Most of the Flex <a href="http://livedocs.adobe.com/flex/3/langref/mx/core/Container.html">Containers</a> have the cornerRadius attribute.  This is a lovely attribute which allows you to round the corners of layout objects.  Better yet, the <a href="http://livedocs.adobe.com/flex/3/langref/mx/containers/Panel.html">Panel</a> and <a href="http://livedocs.adobe.com/flex/3/langref/mx/containers/TitleWindow.html">TitleWindow</a> components let you round the just top corners &#8211; YAY!  So&#8230; why the HELL didn&#8217;t Adobe implement the rounding of <strong>SPECIFIC</strong> corners on any component that had a cornerRadius attribute?!</p>
<p>Anyways, I wanted something like this that I could use in applications for aesthetic purposes.  I found a few solutions here and there which would have been adequate.  However, for educational purposes, I decided to just roll out my own.  Now, there are a few quirks here and there, but overall I am satisfied with the outcome.  Just be careful if you are placing children inside ( take into account padding if you are giving the box heavily rounded corners ).  Additionally, when rounding the corners and using a height / width that scales ( percentage ), it is important to find and use a minHeight and minWidth or else the box <strong>WILL</strong> become all wacked out when it gets small.  It is all relative to the amount of corner radius you specify.  Use the style explorer to see what I mean.</p>
<p>Below is a screen shot of what can be created using this component.</p>
<div align="center">
<img src="http://www.carrythezero.net/software/flex/StyledBox/styledbox_example.jpg" />
</div>
<p>A style explorer can be found <a href="http://carrythezero.net/software/flex/StyledBox/StyledBoxExplorer.swf">here</a> ( with a link to source ).</p>
<p>Source can be downloaded <a href="http://carrythezero.net/software/flex/StyledBox/srcview/StyledBoxExplorer.zip">here</a>.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://carrythezero.net/blog/2009/06/01/flex-rounding-specific-corners-on-a-box/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Flex: control vertical scroll length via mouse wheel events!</title>
		<link>http://carrythezero.net/blog/2009/03/24/flex-control-vertical-scroll-length-via-mouse-wheel-events/</link>
		<comments>http://carrythezero.net/blog/2009/03/24/flex-control-vertical-scroll-length-via-mouse-wheel-events/#comments</comments>
		<pubDate>Wed, 25 Mar 2009 02:56:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://carrythezero.net/blog/?p=184</guid>
		<description><![CDATA[I was recently working with an AdvancedDataGrid that was in charge of presenting a large amount of data to the user.  I was presented with a minor issue (go figure) due to the fact that the max real estate this component could use was about 20% of the total page height.  
The issue:
When [...]]]></description>
			<content:encoded><![CDATA[<p>I was recently working with an <a href="http://livedocs.adobe.com/flex/3/langref/">AdvancedDataGrid</a> that was in charge of presenting a large amount of data to the user.  I was presented with a minor issue (go figure) due to the fact that the max real estate this component could use was about 20% of the total page height.  </p>
<p><strong>The issue:</strong><br />
When scrolling through the data with the mouse wheel, the scroll bar was &#8217;stepping&#8217; to far and some rows were getting cut off.  For example, if there were 40 rows of data and the amount of visible rows was 5, using the mouse wheel to scroll one notch would move the scroll index from position 0 to 7.  This is a problem because it forces the user to either use the scroll arrows or drag the scroll bar to see every row.  Which sucks because mouse wheels rule and make everyone&#8217;s life easier.</p>
<p><strong>The solution:</strong><br />
Intercept the mouse wheel events that are fired and tell the component how to scroll.  It&#8217;s quite simple actually.  The first thing to do is register 2 event listeners on the Component, like so:</p>
<pre class="brush: jscript;">
private function init():void
{
	this.adg.addEventListener(Event.RENDER, this.updateScroll, false, 0, true);
	this.adg.addEventListener(MouseEvent.MOUSE_WHEEL, this.handleMouseWheel, false, 0, true);
}
</pre>
<p>In the function above, <strong>adg</strong> references an AdvancedDataGrid, but that&#8217;s not really important.  The <strong>Event.RENDER</strong> event is dispatched when the display list is about to be updated and rendered (the keyword being &#8216;about&#8217;).  Consult the <a href="http://livedocs.adobe.com/flex/3/langref/flash/display/DisplayObject.html#event:render">API Docs</a> for a better description of this event.  The <strong>MouseEvent.MOUSE_WHEEL</strong> is dispatched whenever the user scrolls with the Mouse Wheel.  </p>
<p>The next part to look at is the method invoked after Event.RENDER is dispatched: updateScroll().  This method simply updates a variable with the vertical scroll position of the Component:</p>
<pre class="brush: jscript;">
private function updateScroll(event:Event):void
{
	this.scrollPos = this.adg.verticalScrollPosition;
}
</pre>
<p>The last part to look at is the method invoked after MouseEvent.MOUSE_WHEEL is fired: handleMouseWheel().  This method uses the scrollPos variable that is constantly being updated via updateScroll() and intercepts mouse wheel events in order to override the behavior of vertical scrolling:</p>
<pre class="brush: jscript;">
private function handleMouseWheel(event:MouseEvent):void
{
	var num:int = event.delta / Math.abs(event.delta);
	if( ( this.scrollPos - num ) &lt;= 0)
		this.adg.scrollToIndex(0);
	} else if( ( this.scrollPos - num ) &gt;= this.adg.maxVerticalScrollPosition ) {
		this.adg.scrollToIndex( this.adg.maxVerticalScrollPosition );
	} else {
		this.adg.scrollToIndex( this.scrollPos - num );
	}
}
</pre>
<p>This is also very straight forward: evaluate the current scroll position and proceed accordingly without causing wacky behavior.  In other words, if the result of (scrollPos &#8211; num) is <= 0 or >= to the max vertical scroll position, send (or keep) the scroll wheel to the appropriate extreme, else scroll 1 unit in the appropriate direction.</p>
<p>Note: eventually I&#8217;ll start adding interactive examples here&#8230; someday.</p>
]]></content:encoded>
			<wfw:commentRss>http://carrythezero.net/blog/2009/03/24/flex-control-vertical-scroll-length-via-mouse-wheel-events/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Best website ever?</title>
		<link>http://carrythezero.net/blog/2009/02/27/best-website-ever/</link>
		<comments>http://carrythezero.net/blog/2009/02/27/best-website-ever/#comments</comments>
		<pubDate>Sat, 28 Feb 2009 03:30:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[random]]></category>

		<guid isPermaLink="false">http://carrythezero.net/blog/?p=213</guid>
		<description><![CDATA[Today a couple of co-workers of mine discovered the best website ever created:
thefuckingweather.com
That is all.  
Oh and this.
]]></description>
			<content:encoded><![CDATA[<p>Today a couple of co-workers of mine discovered the best website ever created:</p>
<p><a href="http://www.thefuckingweather.com">thefuckingweather.com</a></p>
<p>That is all.  </p>
<p>Oh and <a href="http://www.thefuckingvan.com">this.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://carrythezero.net/blog/2009/02/27/best-website-ever/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Slacker Mobile Radio for the Blackberry is sweet.</title>
		<link>http://carrythezero.net/blog/2009/02/25/slacker-mobile-radio-for-the-blackberry-is-sweet/</link>
		<comments>http://carrythezero.net/blog/2009/02/25/slacker-mobile-radio-for-the-blackberry-is-sweet/#comments</comments>
		<pubDate>Thu, 26 Feb 2009 05:39:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[apps]]></category>
		<category><![CDATA[blackberry]]></category>
		<category><![CDATA[music]]></category>

		<guid isPermaLink="false">http://carrythezero.net/blog/?p=181</guid>
		<description><![CDATA[Well I guess I can finally feel good about buying a blackberry and spending $29.99 a month for an unlimited data plan.
Slacker Mobile is a great FREE streaming radio service for the blackberry.  Simply type in an artist / band of your choice and you are instantly taken to your own personalized radio station [...]]]></description>
			<content:encoded><![CDATA[<p>Well I guess I can finally feel good about buying a blackberry and spending $29.99 a month for an unlimited data plan.</p>
<p>Slacker Mobile is a great <strong>FREE</strong> streaming radio service for the blackberry.  Simply type in an artist / band of your choice and you are instantly taken to your own personalized radio station where your chosen band will be played as well as several similar bands (a great way to discover new music).  You can also choose from hundreds of &#8216;expert programmed&#8217; stations.  Better yet, you are given instant access to album info and band bios. </p>
<p>Perhaps the best feature is the ability to cache radio stations to your device&#8217;s memory card.  This way you can listen to music pretty much anywhere&#8230; as long as your device&#8217;s battery isn&#8217;t dead.</p>
<p>Open up your device browser and go to <a href="http://www.slacker.com/mobile/blackberry">http://www.slacker.com/mobile/blackberry/</a> to download and install.</p>
]]></content:encoded>
			<wfw:commentRss>http://carrythezero.net/blog/2009/02/25/slacker-mobile-radio-for-the-blackberry-is-sweet/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Flex: using logical conjunction in an MXML attribute</title>
		<link>http://carrythezero.net/blog/2009/02/12/flex-using-logical-conjunction-in-an-mxml-attribute/</link>
		<comments>http://carrythezero.net/blog/2009/02/12/flex-using-logical-conjunction-in-an-mxml-attribute/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 05:04:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[mxml]]></category>

		<guid isPermaLink="false">http://carrythezero.net/blog/?p=163</guid>
		<description><![CDATA[If you try to use the logical AND operator inside of an MXML attribute to determine its value, the compiler will throw this error:
The entity name must immediately follow the &#8216;&#038;&#8217; in the entity reference
The error message is sketchy, especially given the fact that the logical OR operator is allowed.
The ampersand needs to be html-encoded [...]]]></description>
			<content:encoded><![CDATA[<p>If you try to use the logical AND operator inside of an MXML attribute to determine its value, the compiler will throw this error:</p>
<p><strong>The entity name must immediately follow the &#8216;&#038;&#8217; in the entity reference</strong></p>
<p>The error message is sketchy, especially given the fact that the logical OR operator is allowed.<br />
The ampersand needs to be html-encoded (after all, MXML is an XML-based markup language!)</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; layout=&quot;absolute&quot;&gt;
	&lt;mx:Script&gt;
		&lt;![CDATA[
		[Bindable] private var arg1:Boolean;
		[Bindable] private var arg2:Boolean;

		private function validate():Boolean {
			return (this.arg1 &amp;&amp; this.arg2);
		}
		]]&gt;
	&lt;/mx:Script&gt;

	&lt;!-- bad --&gt;
	&lt;mx:Button enabled=&quot;{(this.arg1) &amp;&amp; (this.arg2)}&quot; /&gt;

	&lt;!-- good --&gt;
	&lt;mx:Button enabled=&quot;{(this.arg1) &amp;amp;&amp;amp; (this.arg2)}&quot; /&gt;

	&lt;!-- also good, but more code --&gt;
	&lt;mx:Button enabled=&quot;{this.validate()}&quot; /&gt;
&lt;/mx:Application&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://carrythezero.net/blog/2009/02/12/flex-using-logical-conjunction-in-an-mxml-attribute/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
