<?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>Thanks, Mister! &#187; Component</title>
	<atom:link href="http://www.thanksmister.com/index.php/archive/category/component/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thanksmister.com</link>
	<description>Flash &#38; Flex Developer</description>
	<lastBuildDate>Mon, 06 Sep 2010 23:10:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Screen Capture with AIR 2 NativeProcess</title>
		<link>http://www.thanksmister.com/index.php/archive/screen-capture-with-air-2-nativeprocess/</link>
		<comments>http://www.thanksmister.com/index.php/archive/screen-capture-with-air-2-nativeprocess/#comments</comments>
		<pubDate>Tue, 25 May 2010 01:20:57 +0000</pubDate>
		<dc:creator>Mister</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Component]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Adobe AIR]]></category>
		<category><![CDATA[Command-line interface]]></category>
		<category><![CDATA[Screenshot]]></category>

		<guid isPermaLink="false">http://thanksmister.com/?p=807</guid>
		<description><![CDATA[Prior to AIR 2 the only way to capture the screen was to use something like Marapi Java Bridge that acts as a conduit between your application and the native system. However, AIR 2 now lets us call With AIR 2 Beta and the upcoming AIR 2 release, you can now use the command-line tool [...]]]></description>
			<content:encoded><![CDATA[<p>Prior to AIR 2 the only way to capture the screen was to use something like <a href="http://blog.everythingflex.com/2008/04/24/do-a-screen-capture-with-adobe-air/">Marapi Java Bridge</a> that acts as a conduit between your application and the native system.  However, AIR 2 now lets us call</p>
<p>With AIR 2 Beta and the upcoming AIR 2 release, you can now use the command-line tool &#8220;screencapture&#8221; that comes with Mac OS.   Nothing extra needs to be bundled with the application for this to work on a Mac, but on Windows, you need an additional piece of code to execute the screen capture process.</p>
<p>The process of doing a screen capture is pretty easy.   You first create a File object that points to the location of the &#8220;screencapture&#8221; command line on the Mac:</p>
<p><span id="more-807"></span></p>
<div class="codecolorer-container actionscript mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">var</span> file:File = File.<span style="color: #006600;">applicationDirectory</span>;<br />
file = file.<span style="color: #006600;">resolvePath</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;usr/sbin/screencapture&quot;</span><span style="color: #66cc66;">&#41;</span>;</div></td></tr></tbody></table></div>
<p>Then create a <a href="http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/flash/desktop/NativeProcessStartupInfo.html">NativeProcessStartupInfo</a> object that will be used when we start the <a href="http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/flash/desktop/NativeProcess.html">NativeProcess</a>.The arguments property of the NativeProcessStartupInfo takes a list of arguments that will be passed to the command line tool when its started.  For a complete list of arguments used by the screencapture command line tool, type &#8220;screencapture &#8211;help&#8221; in the terminal window.  For this example I wanted to push out a file named &#8220;screencap.png&#8221; to the desktop from a selection of the screen.  Optionally, you could capture the image to the clipboard and paste it directly.</p>
<div class="codecolorer-container actionscript mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">var</span> nativeProcessStartupInfo:NativeProcessStartupInfo = <span style="color: #000000; font-weight: bold;">new</span> NativeProcessStartupInfo<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #000000; font-weight: bold;">var</span> args:Vector. = <span style="color: #000000; font-weight: bold;">new</span> Vector.<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">&quot;-i&quot;</span>;<br />
args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">&quot;screencapture.png&quot;</span>;<br />
<br />
nativeProcessStartupInfo.<span style="color: #0066CC;">arguments</span> = args;<br />
nativeProcessStartupInfo.<span style="color: #006600;">executable</span> = file;</div></td></tr></tbody></table></div>
<p>Now we can start the native process:</p>
<div class="codecolorer-container actionscript mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">process = <span style="color: #000000; font-weight: bold;">new</span> NativeProcess<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
process.<span style="color: #0066CC;">start</span><span style="color: #66cc66;">&#40;</span>nativeProcessStartupInfo<span style="color: #66cc66;">&#41;</span>;</div></td></tr></tbody></table></div>
<p>The screencapture command tool will be launched and you will see the selection cursor on your screen.  After you make a selection, the file will automatically be saved to the desktop as &#8220;screencapture.png&#8221;.</p>
<p>Here is the complete project code:</p>
<div class="codecolorer-container actionscript mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:640px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br /></div></td><td><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span><br />
xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/mx&quot;</span> creationComplete=<span style="color: #ff0000;">&quot;init()&quot;</span><span style="color: #66cc66;">&amp;</span>gt;<br />
<br />
<span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span><br />
<br />
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> process:NativeProcess;<br />
<br />
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
<span style="color: #66cc66;">&#123;</span><br />
launchNativeProcess<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> launchNativeProcess<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
<span style="color: #66cc66;">&#123;</span><br />
<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>NativeProcess.<span style="color: #006600;">isSupported</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">var</span> file:File = File.<span style="color: #006600;">applicationDirectory</span>;<br />
<br />
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Capabilities</span>.<span style="color: #0066CC;">os</span>.<span style="color: #0066CC;">toLowerCase</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;win&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&gt;</span> -<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
<span style="color: #808080; font-style: italic;">//file = file.resolvePath(&quot;bin/mylocalexe.exe&quot;);</span><br />
<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Capabilities</span>.<span style="color: #0066CC;">os</span>.<span style="color: #0066CC;">toLowerCase</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;mac&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&gt;</span> -<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
file = file.<span style="color: #006600;">resolvePath</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;/usr/sbin/screencapture&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">var</span> args:Vector.<span style="color: #66cc66;">&lt;</span>String<span style="color: #66cc66;">&gt;</span> = <span style="color: #000000; font-weight: bold;">new</span> Vector.<span style="color: #66cc66;">&lt;</span>String<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">&quot;-i&quot;</span>;<br />
args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">&quot;screencapture.png&quot;</span>;<br />
<br />
<span style="color: #000000; font-weight: bold;">var</span> nativeProcessStartupInfo:NativeProcessStartupInfo = <span style="color: #000000; font-weight: bold;">new</span> NativeProcessStartupInfo<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
nativeProcessStartupInfo.<span style="color: #0066CC;">arguments</span> = args;<br />
nativeProcessStartupInfo.<span style="color: #006600;">executable</span> = file;<br />
nativeProcessStartupInfo.<span style="color: #006600;">workingDirectory</span> = File.<span style="color: #006600;">desktopDirectory</span>;<br />
<br />
process = <span style="color: #000000; font-weight: bold;">new</span> NativeProcess<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
process.<span style="color: #0066CC;">start</span><span style="color: #66cc66;">&#40;</span>nativeProcessStartupInfo<span style="color: #66cc66;">&#41;</span>;<br />
<br />
<span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span></div></td></tr></tbody></table></div>
<p>To get something like this to work on Windows, you need to know a little bit of C or C# so you can call your own service and launch the screen print functionality on Windows. For more about using the NativeProcess in AIR 2 for both Windows and Mac, you check out this <a href="http://www.adobe.com/devnet/air/flex/quickstart/interacting_with_native_process.html">Adobe article</a>.</p>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/ea2c0ce1-6d29-4a27-b680-848f9c046997/"><img class="zemanta-pixie-img" style="border: medium none; float: right;" src="http://img.zemanta.com/reblog_e.png?x-id=ea2c0ce1-6d29-4a27-b680-848f9c046997" alt="Reblog this post [with Zemanta]" /></a><span class="zem-script more-related pretty-attribution"><script src="http://static.zemanta.com/readside/loader.js" type="text/javascript"></script></span></div>
<p><map name='google_ad_map_807_1452acacd61817fb'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/807?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_807_1452acacd61817fb' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=807&amp;url= http%3A%2F%2Fwww.thanksmister.com%2Findex.php%2Farchive%2Fscreen-capture-with-air-2-nativeprocess%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.thanksmister.com/index.php/archive/screen-capture-with-air-2-nativeprocess/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Smooth Scrolling HorizontalList</title>
		<link>http://www.thanksmister.com/index.php/archive/smooth-scrolling-horizontallist/</link>
		<comments>http://www.thanksmister.com/index.php/archive/smooth-scrolling-horizontallist/#comments</comments>
		<pubDate>Wed, 04 Mar 2009 05:06:04 +0000</pubDate>
		<dc:creator>Mister</dc:creator>
				<category><![CDATA[Component]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[HorizontalList]]></category>

		<guid isPermaLink="false">http://thanksmister.com/?p=450</guid>
		<description><![CDATA[This example is based on Alex Harui&#8217;s Smooth Scrolling List. It just changes the code to work with the HorizontalList control rather than the List control. The SmoothHorizontalScrollingList class extends the HorizontalList control adding the needed functionality to allow smooth scrolling: Example Source file: smoothscrollinghorizontallist.zip Below is the full code for the example. Code 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596package [...]]]></description>
			<content:encoded><![CDATA[<p>This example is based on Alex Harui&#8217;s <a href="http://blogs.adobe.com/aharui/2008/03/smooth_scrolling_list.html">Smooth Scrolling List</a>.  It just changes the code to work with the HorizontalList control rather than the List control.  The SmoothHorizontalScrollingList class extends the HorizontalList control adding the needed functionality to allow smooth scrolling:</p>
<p><span id="more-450"></span></p>
<p><strong>Example</strong></p>
<div id="smoothscroll">
        <object type="application/x-shockwave-flash" id="superimage" data= "http://thanksmister.com/examples/smoothscrollinghorizontallist/smoothscrollinghorizontallist.swf" width="388" height="213"><param name="movie" value= "http://thanksmister.com/examples/smoothscrollinghorizontallist/smoothscrollinghorizontallist.swf" /><param name="allowScriptAccess" value="always" /><param name="wmode" value="transparent" /></object>
</div>
<p><p>
Source file: <a href="http://thanksmister.com/examples/smoothscrollinghorizontallist/smoothscrollinghorizontallist.zip">smoothscrollinghorizontallist.zip</a></p>
<p>Below is the full code for the example. </p>
<p><strong>Code</strong></p>
<div class="codecolorer-container actionscript mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:640px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br /></div></td><td><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">package com.<span style="color: #006600;">custom</span>.<span style="color: #006600;">controls</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">DisplayObject</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">Event</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">MouseEvent</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">HorizontalList</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">ScrollPolicy</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">effects</span>.<span style="color: #006600;">easing</span>.<span style="color: #66cc66;">*</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">events</span>.<span style="color: #006600;">ScrollEvent</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">events</span>.<span style="color: #006600;">ScrollEventDetail</span>;<br />
<br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp;* &nbsp;List that uses smooth scrolling<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SmoothHorizontalScrollingList <span style="color: #0066CC;">extends</span> HorizontalList<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> fudge:<span style="color: #0066CC;">Number</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> SmoothHorizontalScrollingList<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offscreenExtraRowsOrColumns = <span style="color: #cc66cc;">2</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; override protected <span style="color: #000000; font-weight: bold;">function</span> configureScrollBars<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">super</span>.<span style="color: #006600;">configureScrollBars</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>horizontalScrollBar<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; horizontalScrollBar.<span style="color: #006600;">lineScrollSize</span> = .125; &nbsp;<span style="color: #808080; font-style: italic;">// should be inverse power of 2</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; override <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> horizontalScrollPosition<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Number</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span><span style="color: #0066CC;">isNaN</span><span style="color: #66cc66;">&#40;</span>fudge<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> vsp:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">super</span>.<span style="color: #006600;">horizontalScrollPosition</span> + fudge;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fudge = <span style="color: #0066CC;">NaN</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> vsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">floor</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">super</span>.<span style="color: #006600;">horizontalScrollPosition</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; override protected <span style="color: #000000; font-weight: bold;">function</span> scrollHandler<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// going backward is trickier. &nbsp;When you cross from, for instance 2.1 to 1.9, you need to convince</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// the superclass that it is going from 2 to 1 so the delta is -1 and not -.2.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// we do this by adding a fudge factor to the first return from horizontalScrollPosition</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// which is used by the superclass logic.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> last:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">super</span>.<span style="color: #006600;">horizontalScrollPosition</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> vsp:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">this</span>.<span style="color: #006600;">horizontalScrollBar</span>.<span style="color: #006600;">scrollPosition</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>vsp <span style="color: #66cc66;">&lt;</span> last<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>last <span style="color: #66cc66;">!</span>= <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">floor</span><span style="color: #66cc66;">&#40;</span>last<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">||</span> vsp <span style="color: #66cc66;">!</span>= <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">floor</span><span style="color: #66cc66;">&#40;</span>vsp<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">floor</span><span style="color: #66cc66;">&#40;</span>vsp<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&lt;</span> <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">floor</span><span style="color: #66cc66;">&#40;</span>last<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fudge = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">floor</span><span style="color: #66cc66;">&#40;</span>last<span style="color: #66cc66;">&#41;</span> - <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">floor</span><span style="color: #66cc66;">&#40;</span>horizontalScrollBar.<span style="color: #006600;">scrollPosition</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>last.<span style="color: #006600;">toFixed</span><span style="color: #66cc66;">&#40;</span>2<span style="color: #66cc66;">&#41;</span>, vsp.<span style="color: #006600;">toFixed</span><span style="color: #66cc66;">&#40;</span>2<span style="color: #66cc66;">&#41;</span>, fudge<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">super</span>.<span style="color: #006600;">scrollHandler</span><span style="color: #66cc66;">&#40;</span>event<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> pos:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">super</span>.<span style="color: #006600;">horizontalScrollPosition</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// if we get a THUMB_TRACK, then we need to calculate the position</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// because it gets rounded to an int by the ScrollThumb code, and </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// we want fractional values.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>event is ScrollEvent<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> se:ScrollEvent = ScrollEvent<span style="color: #66cc66;">&#40;</span>event<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>se.<span style="color: #006600;">detail</span> == ScrollEventDetail.<span style="color: #006600;">THUMB_TRACK</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>horizontalScrollBar.<span style="color: #006600;">numChildren</span> == 4<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> downArrow:DisplayObject = horizontalScrollBar.<span style="color: #006600;">getChildAt</span><span style="color: #66cc66;">&#40;</span>3<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> thumb:DisplayObject = horizontalScrollBar.<span style="color: #006600;">getChildAt</span><span style="color: #66cc66;">&#40;</span>2<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pos = <span style="color: #66cc66;">&#40;</span>thumb.<span style="color: #006600;">y</span> - downArrow.<span style="color: #0066CC;">height</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">/</span> <span style="color: #66cc66;">&#40;</span>downArrow.<span style="color: #006600;">y</span> - thumb.<span style="color: #0066CC;">height</span> - downArrow.<span style="color: #0066CC;">height</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> <span style="color: #0066CC;">this</span>.<span style="color: #006600;">maxHorizontalScrollPosition</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// round to nearest lineScrollSize;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pos <span style="color: #66cc66;">/</span>= horizontalScrollBar.<span style="color: #006600;">lineScrollSize</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pos = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">round</span><span style="color: #66cc66;">&#40;</span>pos<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pos <span style="color: #66cc66;">*</span>= horizontalScrollBar.<span style="color: #006600;">lineScrollSize</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//trace(&quot;faked&quot;, pos);</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> fraction:<span style="color: #0066CC;">Number</span> = pos - horizontalScrollPosition;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fraction <span style="color: #66cc66;">*</span>= <span style="color: #0066CC;">this</span>.<span style="color: #006600;">columnWidth</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//trace(&quot;was&quot;, listContent.y.toFixed(2));</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; listContent.<span style="color: #006600;">move</span><span style="color: #66cc66;">&#40;</span>viewMetrics.<span style="color: #0066CC;">left</span> + listContent.<span style="color: #006600;">leftOffset</span> - fraction, listContent.<span style="color: #006600;">y</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//trace(&quot;now&quot;, listContent.y.toFixed(2), fraction.toFixed(2), listItems[0][0].data.lastName);</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div></td></tr></tbody></table></div>
<p>The following code is an example of how to use the custom control in a Flex application:</p>
<div class="codecolorer-container actionscript mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:640px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br /></div></td><td><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&lt;</span>?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #66cc66;">&gt;</span><br />
<span style="color: #66cc66;">&lt;</span>mx:Application xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> layout=<span style="color: #ff0000;">&quot;absolute&quot;</span> xmlns:controls=<span style="color: #ff0000;">&quot;com.custom.controls.*&quot;</span> creationComplete=<span style="color: #ff0000;">&quot;init()&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;383&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;388&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>mx:Script<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">collections</span>.<span style="color: #006600;">ArrayCollection</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _dataProvider:ArrayCollection;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _dataProvider = <span style="color: #000000; font-weight: bold;">new</span> ArrayCollection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _dataProvider.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>title:<span style="color: #ff0000;">&quot;Louis Leakey&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _dataProvider.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>title:<span style="color: #ff0000;">&quot;Mary Leakey&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _dataProvider.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>title:<span style="color: #ff0000;">&quot;Richard Leakey&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _dataProvider.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>title:<span style="color: #ff0000;">&quot;Margaret Mead&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _dataProvider.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>title:<span style="color: #ff0000;">&quot;Jane Goodall&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _dataProvider.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>title:<span style="color: #ff0000;">&quot;Ruth Benedict&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _dataProvider.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>title:<span style="color: #ff0000;">&quot;Franz Boas&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _dataProvider.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>title:<span style="color: #ff0000;">&quot;Claude Levi Strauss&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _dataProvider.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>title:<span style="color: #ff0000;">&quot;Noam Chomsky&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _dataProvider.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>title:<span style="color: #ff0000;">&quot;James Deetz &quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _dataProvider.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>title:<span style="color: #ff0000;">&quot;Sir Arthur Evans&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _dataProvider.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>title:<span style="color: #ff0000;">&quot;Pere Bosch-Gimpera&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _dataProvider.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>title:<span style="color: #ff0000;">&quot;Kathleen Kenyon&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _dataProvider.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>title:<span style="color: #ff0000;">&quot;Colin Renfrew&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _dataProvider.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>title:<span style="color: #ff0000;">&quot;Mortimer Wheeler&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _dataProvider.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>title:<span style="color: #ff0000;">&quot;Leonard Woolley&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _dataProvider.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>title:<span style="color: #ff0000;">&quot;Lewis Binford&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _dataProvider.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>title:<span style="color: #ff0000;">&quot;Howard Carte&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _dataProvider.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>title:<span style="color: #ff0000;">&quot;Donald Johansen&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _dataProvider.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>title:<span style="color: #ff0000;">&quot;Phil Harding&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _dataProvider.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>title:<span style="color: #ff0000;">&quot;Alfred Foucher&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _dataProvider.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>title:<span style="color: #ff0000;">&quot;Heinrich Schliemann&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _dataProvider.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>title:<span style="color: #ff0000;">&quot;Mick Aston&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _dataProvider.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>title:<span style="color: #ff0000;">&quot;Barry Cunliffe&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _dataProvider.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>title:<span style="color: #ff0000;">&quot;Churchill Babington&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _dataProvider.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>title:<span style="color: #ff0000;">&quot;Vere Gordon Childe&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _dataProvider.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>title:<span style="color: #ff0000;">&quot;Gustaf VI Adolf&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getTitle<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">data</span>:<span style="color: #0066CC;">Object</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0066CC;">data</span>.<span style="color: #006600;">title</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>mx:Script<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>mx:HBox <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;100%&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;200&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>controls:SmoothHorizontalScrollingList <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dataProvider=<span style="color: #ff0000;">&quot;{_dataProvider}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;100%&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;100%&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>controls:itemRenderer<span style="color: #66cc66;">&gt;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>mx:Component<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">Text</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;{outerDocument.getTitle(data)}&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>mx:Component<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>controls:itemRenderer<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>controls:SmoothHorizontalScrollingList<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>mx:HBox<span style="color: #66cc66;">&gt;</span><br />
<span style="color: #66cc66;">&lt;/</span>mx:Application<span style="color: #66cc66;">&gt;</span></div></td></tr></tbody></table></div>
<p><strong>Good, but&#8230;</strong></p>
<p>What I would like to do is make it so the list scrolls smoothtly without the the horizontal scroll bars visible.  However, I can&#8217;t yet figure out how to do this by changing just the horizontalScrollPosition, it seems to revert back to the default behavior for scrolling or blows up when you scroll from the right back to the left.  I quickly began to see that to get a smooth scrolling list within Flex you would have to use an VBox or HBox container with a repeater.   This method is outlined by <a href="http://weblogs.macromedia.com/pent/archives/2008/03/itemrenderers_p_3.html">Peter Ent &#8220;itemRenderers: Part 4: States and Transitions&#8221;</a>. </p>
<p><strong>Update</strong></p>
<p>Found an <a href="http://blog.appdivision.com/2009/02/24/flex-overriding-scrolltoindex-in-horizontallist-to-animate-scrolling/">interesting post </a>for overriding the scrollToIndex method of the HorizontalList control to allow for animated scrolling using external buttons, the only issue is that I couldn&#8217;t scroll from the end of the list back to the beginning.    I also found a <a href="http://bkflex.wordpress.com/2007/07/05/flex-3-built-in-data-grid-animation-effects/">blog post</a> about built in animation effects for Flex 3 List controls using mx.effects.DefaultTileListEffect.  However, it seems you need to use this only for a List or TileList component rather than a HorizontalList: <strong> itemsChangeEffect=&#8221;{mx.effects.DefaultListEffect}&#8221; </strong>.   I have not tried this method yet to animate a list, but it may prove promising if its actually what it claims to be. </p>
<p><strong>Another Solution</strong></p>
<p><a href="http://www.returnundefined.com/2009/03/smooth-scrolling-flex-list">Ben Clinkinbeard of &#8220;returned undefined;&#8221; blog and UM fame posted a great little example of a Smooth Scrolling List</a> that takes a List control and wraps it in a Canvas container to achieve the smooth scrolling effect.   This technique has the benefit of keeping the functionality of the list but also allowing you to smoothly scroll the list by using and external tween.  It should be easy to convert this to a horizontal list and retain the smooth scrolling effect.    Of course, the downside to this method is that you have to render the entire list, which wouldn&#8217;t be very pleasant for large data sets, but for my needs this works great since my data set is very small.  I have also experienced some resize issues when deleting items from the list.  Here is an example of a Smooth Scrolling HorizontalList using a modified version of Ben&#8217;s technique:</p>
<div id="smoothscroll">
        <object type="application/x-shockwave-flash" id="superimage" data= "http://thanksmister.com/examples/smoothscrollinghorizontallist/smoothscrollinghorizontallist2.swf" width="388" height="259"><param name="movie" value= "http://thanksmister.com/examples/smoothscrollinghorizontallist/smoothscrollinghorizontallist.swf" /><param name="allowScriptAccess" value="always" /><param name="wmode" value="transparent" /></object>
</div>
<p>
<p>The code for the SmoothScrollingHorizontalList class:</p>
<div class="codecolorer-container actionscript mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:640px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br /></div></td><td><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">/**<br />
&nbsp;* &nbsp;Original code from Ben Clinkinbeard (http://www.returnundefined.com/2009/03/smooth-scrolling-flex-list);<br />
&nbsp;* */</span><br />
package com.<span style="color: #006600;">benclinkinbeard</span>.<span style="color: #006600;">controls</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">HorizontalList</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">Container</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">ScrollPolicy</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">mx_internal</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">events</span>.<span style="color: #006600;">FlexEvent</span>;<br />
<br />
&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SmoothScrollingHorizontalList <span style="color: #0066CC;">extends</span> HorizontalList<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> SmoothScrollingHorizontalList<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// required to ensure all renderers get created</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;paddingRight&quot;</span>, -1 <span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// parent container will handle scrolling</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; horizontalScrollPolicy = ScrollPolicy.<span style="color: #006600;">OFF</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addEventListener<span style="color: #66cc66;">&#40;</span> FlexEvent.<span style="color: #006600;">UPDATE_COMPLETE</span>, handleUpdateComplete <span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleUpdateComplete<span style="color: #66cc66;">&#40;</span> event:FlexEvent <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">var</span> combinedRendererWidth:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// iterate over list of renderers provided by our List subclass</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// but since HorozintalList does not have variable column widths, we use columnWidth</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #b1b100;">each</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">var</span> renderer:<span style="color: #0066CC;">Object</span> <span style="color: #b1b100;">in</span> renderers <span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; combinedRendererWidth += columnWidth;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// list needs to be at least 10 pixels wide to show results</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// and always needs to be 10 pixels wider than the combined width of the renderers</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">width</span> = combinedRendererWidth + <span style="color: #cc66cc;">10</span>; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// need to shrink list height when canvas has a scrollbar so the scrollbar doesn't overlap the list</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">height</span> = <span style="color: #66cc66;">&#40;</span> Container<span style="color: #66cc66;">&#40;</span> parent <span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">maxHorizontalScrollPosition</span> <span style="color: #66cc66;">&gt;</span> 0 <span style="color: #66cc66;">&#41;</span> ? parent.<span style="color: #0066CC;">height</span> - 16 : parent.<span style="color: #0066CC;">height</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// set the row height to height of list</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rowHeight = <span style="color: #0066CC;">height</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// array of renderers being used in this list</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> renderers<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Array</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// prefix the internal property name with its namespace</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> rawArray:<span style="color: #0066CC;">Array</span> = mx_internal::rendererArray;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> arr:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// the rendererArray is a bit messy</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// its an Array of Arrays, except sometimes the sub arrays are empty</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// and sometimes it contains entries that aren't Arrays at all</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #b1b100;">each</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">var</span> obj:<span style="color: #0066CC;">Object</span> <span style="color: #b1b100;">in</span> rawArray <span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> rendererArray:<span style="color: #0066CC;">Array</span> = obj as <span style="color: #0066CC;">Array</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// make sure we have an Array and there is something in it</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span> rendererArray <span style="color: #66cc66;">&amp;&amp;</span> rendererArray.<span style="color: #0066CC;">length</span> <span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// if there is something in it, the first item is our renderer</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// but this doesn't seem to be the case for HorizontalList because obj[0] is always empty?</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">//arr.push( obj[ 0 ] );</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;arr = rendererArray;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> arr;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div></td></tr></tbody></table></div>
<p>The source code for the example: <a href="http://thanksmister.com/examples/smoothscrollinghorizontallist/smoothscrollinghorizontallist2.zip">smoothscrollinghorizontallist2.zip</a></p>
<p>-Mister</p>
<p><map name='google_ad_map_450_1452acacd61817fb'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/450?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_450_1452acacd61817fb' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=450&amp;url= http%3A%2F%2Fwww.thanksmister.com%2Findex.php%2Farchive%2Fsmooth-scrolling-horizontallist%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.thanksmister.com/index.php/archive/smooth-scrolling-horizontallist/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Flex :: ImageCache, a cheap way to cache images</title>
		<link>http://www.thanksmister.com/index.php/archive/flex-imagecache-a-cheap-way-to-cache-images/</link>
		<comments>http://www.thanksmister.com/index.php/archive/flex-imagecache-a-cheap-way-to-cache-images/#comments</comments>
		<pubDate>Fri, 30 Jan 2009 04:55:53 +0000</pubDate>
		<dc:creator>Mister</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Component]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[BitmapData]]></category>
		<category><![CDATA[Image]]></category>
		<category><![CDATA[ItemRenderer]]></category>
		<category><![CDATA[List]]></category>
		<category><![CDATA[TitleList]]></category>

		<guid isPermaLink="false">http://thanksmister.com/?p=336</guid>
		<description><![CDATA[In a previous post about Ely&#8217;s SuperImage, I mentioned that we decided to implement a simpler method for caching images within a Flex application. ImageCache is a simple class file that extends the Image control by adding the ability for the control to cache bitmap data. Unlike SuperImage, ImacheCache can handled SWF files, it just [...]]]></description>
			<content:encoded><![CDATA[<p>In a previous <a href="http://thanksmister.com/?p=265">post</a> about <a href="http://www.quietlyscheming.com/blog/2007/01/23/some-thoughts-on-doubt-on-flex-as-the-best-option-orhow-i-made-my-flex-images-stop-dancing/">Ely&#8217;s SuperImage</a>, I mentioned that we decided to implement a simpler method for caching images within a Flex application.   ImageCache is a simple class file that extends the Image control by adding the ability for the control to cache bitmap data.  Unlike SuperImage, ImacheCache can handled SWF files, it just lacks all the bells and whistles of SuperImage, though image flicker is eliminated.    </p>
<p><strong>Using ImageCache</strong></p>
<p>ImacheCache is just two class files.  ImageCache.as which extends the Image control and ImageCachUtility.as which is a Singleton class that used by Imagecache to store and retrieve the BitmapData for cached images.  Bitmap data is stored in a regular ArrayCollection object and retrieved by using the full path to the image (because image names can be duplicates but paths should be unique).  Once the amount of cached images reaches the cache limit, the controls works on first in first out, dropping off older cached images as it caches new ones and staying within the cache limit.  SWF fiels are not actually cached and will load as normal.   You just use ImageCache like you would the Image control within your project:</p>
<div class="codecolorer-container actionscript mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&lt;</span>controls:ImageCache cacheLimit=<span style="color: #ff0000;">&quot;200&quot;</span> id=<span style="color: #ff0000;">&quot;image&quot;</span> source=<span style="color: #ff0000;">&quot;{data.url}&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;100&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;100&quot;</span> complete=<span style="color: #ff0000;">&quot;imageComplete()&quot;</span> ioError=<span style="color: #ff0000;">&quot;imageError()&quot;</span> xmlns:controls=<span style="color: #ff0000;">&quot;com.thanksmister.controls.*&quot;</span><span style="color: #66cc66;">/&gt;</span></div></td></tr></tbody></table></div>
<p><strong>Cache Limit</strong></p>
<p>ImageCache has a property called &#8220;cacheLimit&#8221; which tells the control how many images to cache.  Because caching images can reduce the performance of your application.  The larger the cache limit value, the more memory your application will use because it is storing all the Bitmap data in memory. If you want to reset the image cache, create an instance of the ImageCacheUtility and call the method &#8220;clear()&#8221;. ImageCache has been used and tested extensively for large media sites.  Below is a screen shot of  images from Flickr, the list on the left uses the standard Image control, the list on the right uses the ImageCache control.  <strong> It seems that there may be some security issue when loading Flickr images without doing a proxying the images.  Run the example locally or proxy Flickr images for best results.</strong></p>
<p><span id="more-336"></span></p>
<p><strong>Example</strong></p>
<p><img alt="" src="http://thanksmister.com/examples/imagecache/ImageCache.png" title="ImageCache" class="alignnone" width="639" height="540" /></p>
<p>
<p>
<strong>Code</strong></p>
<p>You can download the code for the above project <a href="http://thanksmister.com/examples/imagecache/ImageCache.zip">here</a>.  You will need your own <a href="http://www.flickr.com/services/">Flickr API</a> key to make the application work.  </p>
<p>-Mister</p>
<p><map name='google_ad_map_336_1452acacd61817fb'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/336?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_336_1452acacd61817fb' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=336&amp;url= http%3A%2F%2Fwww.thanksmister.com%2Findex.php%2Farchive%2Fflex-imagecache-a-cheap-way-to-cache-images%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.thanksmister.com/index.php/archive/flex-imagecache-a-cheap-way-to-cache-images/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Scrolling List Control with Tweener</title>
		<link>http://www.thanksmister.com/index.php/archive/scrolling-list-control-with-tweener/</link>
		<comments>http://www.thanksmister.com/index.php/archive/scrolling-list-control-with-tweener/#comments</comments>
		<pubDate>Mon, 26 Jan 2009 06:24:21 +0000</pubDate>
		<dc:creator>Mister</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Component]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Effects]]></category>
		<category><![CDATA[List]]></category>
		<category><![CDATA[maxVerticalScrollPosition]]></category>
		<category><![CDATA[Mouse Wheel]]></category>
		<category><![CDATA[Scrollbar]]></category>
		<category><![CDATA[Tween]]></category>
		<category><![CDATA[verticalScrollPosition]]></category>

		<guid isPermaLink="false">http://thanksmister.com/?p=305</guid>
		<description><![CDATA[I was on a simple little side task last week, to create a scrolling effect using the Flex control and also remove the default scroll bars. I didn&#8217;t want to do the usual trick, scrolling a HBox with items added to it using a repeater, or whatever. I wanted to animate the scrolling that occurs [...]]]></description>
			<content:encoded><![CDATA[<p>I was on a simple little side task last week, to create a scrolling effect using the Flex control and also remove the default scroll bars.  I didn&#8217;t want to do the usual trick, scrolling a HBox with items added to it using a repeater, or whatever.   I wanted to animate the scrolling that occurs within an actual List control but give it a little easing effect.   The call went out to Twitter for suggestions, and within minutes <a href="http://www.jessewarden.com">Jesse Warden</a> responded with with &#8220;use the tween class dude&#8221; and also my friend Jerry Don reminded me of a new smooth scrolling List created by <a href="http://blogs.adobe.com/aharui/2008/03/smooth_scrolling_list.html">Alex Harui</a>.    This helped to point me in the right direction.</p>
<p><strong>Scrollbars and Mouse Wheel</strong></p>
<p>The first objective was to remove the default List scroll bar because I wanted to use buttons to scroll the list from the top to bottom and vice versa with just one click of a button.  Ok, no problem, verticalScrollPolicy=&#8221;off&#8221; just hides the scroll bar, however it also removes the ability to scroll the list with the mouse wheel.   Now I had to hack into the List control to add this functionality back.  This part was not too hard, I found a good <a href="http://blog.marlon.be/tag/flex/">code example</a>, though it was in German, and repurposed it for my needs. </p>
<p><span id="more-305"></span></p>
<div class="codecolorer-container actionscript mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:640px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br /></div></td><td><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">/**<br />
* Override the mouseWheelHandler so if the verticalScrollPolicy is &quot;off&quot;<br />
* we use the MouseEvent.delta value to manually update the List control<br />
* scroll position when there is no ScrollBar.<br />
*<br />
* */</span><br />
override protected <span style="color: #000000; font-weight: bold;">function</span> mouseWheelHandler<span style="color: #66cc66;">&#40;</span>event:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>verticalScrollPolicy == ScrollPolicy.<span style="color: #006600;">OFF</span> <span style="color: #66cc66;">&amp;&amp;</span> maxVerticalScrollPosition <span style="color: #66cc66;">!</span>= 0<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> len:<span style="color: #0066CC;">Number</span> = dataProvider.<span style="color: #0066CC;">length</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> delta:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#40;</span>event.<span style="color: #006600;">delta</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> pos:<span style="color: #0066CC;">Number</span> = verticalScrollPosition;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> newpos:<span style="color: #0066CC;">Number</span> = verticalScrollPosition;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>delta <span style="color: #66cc66;">&lt;</span> 0<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delta = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">abs</span><span style="color: #66cc66;">&#40;</span>delta<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>pos + delta <span style="color: #66cc66;">&gt;</span>= maxVerticalScrollPosition<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newpos = maxVerticalScrollPosition;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newpos = pos + <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">abs</span><span style="color: #66cc66;">&#40;</span>delta<span style="color: #66cc66;">&#41;</span>; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>pos - delta<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&lt;</span>= 0 <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">||</span> pos == 0<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newpos = <span style="color: #cc66cc;">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newpos = pos - delta;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; verticalScrollPosition = newpos;<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0066CC;">super</span>.<span style="color: #006600;">mouseWheelHandler</span><span style="color: #66cc66;">&#40;</span>event<span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span></div></td></tr></tbody></table></div>
<p><strong>Tween List</strong></p>
<p>I then through on some buttons that would scroll the list from the current position to either the start or the end.  Now began the work with to add the easing function so the list would scroll fast at the start of the scroll and then slow down just before reaching the end or beginning of the list, depending on which way you want to scroll.    I started with the built in mx.effects.Tween class which really proved to be the least effective.   One problem with the List control is that its not incremental, it scrolls by row, making for a choppy scroll experience.   So instead of being able to scroll in smaller increments, you have to scroll by whole numbers, which doesn&#8217;t allow enough runway to make the list easing effect noticeable.     Using the regular Tween and a mx.effects.easing.Circle effect might look something like this:</p>
<div class="codecolorer-container actionscript mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br /></div></td><td><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> tweenDown<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">var</span> pos:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">list</span>.<span style="color: #006600;">verticalScrollPosition</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">end</span>:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">list</span>.<span style="color: #006600;">maxVerticalScrollPosition</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">var</span> tween:Tween = <span style="color: #000000; font-weight: bold;">new</span> Tween<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span>, pos, <span style="color: #0066CC;">end</span>, 1400, 10, tweenUpdateHandler, tweenEndHandler<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp;tween.<span style="color: #006600;">easingFunction</span> = Circular.<span style="color: #006600;">easeOut</span>;<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> tweenUpdateHandler<span style="color: #66cc66;">&#40;</span>value:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">list</span>.<span style="color: #006600;">verticalScrollPosition</span> = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">round</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#40;</span>value<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> tweenEndHandler<span style="color: #66cc66;">&#40;</span>value:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'tween end value: '</span> + value<span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span></div></td></tr></tbody></table></div>
<p>Notice that you need to round the value returned in the tweenUpdateFunction, if you don&#8217;t, then your list will get hosed because the list can&#8217;t handle values like</p>
<blockquote><p>
tween value: 0.03486542280255378<br />
tween value: 0.01960467102681207<br />
tween value: 0.01022360862317484<br />
tween value: 0.0032527319110684516<br />
tween value: 0.0001680006720050642
</p></blockquote>
<p>
<p>
<strong>Smooth Scrolling List</strong></p>
<p>This is where I thought Alex&#8217;s smooth scrolling list would come into play because it allows for or smooth scrolling by increments.   In theory, you shouldn&#8217;t have to round up the number, you should be able to apply the values directly to the verticalScrollPosition property of the list.   Alex&#8217;s prototype is suppose to allow this, which it does to some extent.  The prototype list can handle it when you scroll down, but not back up to the top, it breaks down. So this doesn&#8217;t really solve the problem of smoothly scrolling the list when updating the verticalScrollPosition with a Tween effect.   However, his list does have some value as it allows for smooth scrolling when you use the mouse wheel.  </p>
<p><strong>Example</strong></p>
<p>Below is the example and code.  Don&#8217;t expect the mouse wheel to work if you are on Mac OS X, because its not supported in the Flash Player.  If you are interested in a work around for the mouse wheel issue, check out this <a href="http://blog.pixelbreaker.com/2006/11/08/flash/swfmacmousewheel/">the piexelbreaker.com post</a> for a workaround. Of course the mouse wheel works fine in Adobe AIR.  Also, the longer the list of data, the better the animation effect because there is more data to show the full effect.  The effect could still be improved, but until Adobe releases a new set of List components that scroll properly, this is as good as it may get.   Let me know if anyone has any other suggestions.</p>
<div id="flexapp">
        <object type="application/x-shockwave-flash" id="superimage" data= "http://thanksmister.com/examples/scrolltweeneffect/scrolltweeneffect.swf" width="300" height="300"><param name="movie" value= "http://thanksmister.com/examples/scrolltweeneffect/scrolltweeneffect.swf" /><param name="allowScriptAccess" value="always" /><param name="wmode" value="transparent" /></object>
</div>
<p>
<p>
Download the <a href="http://thanksmister.com/examples/scrolltweeneffect/ScrollTweenEffect.zip">ScrollTweenEffect.zip</a> file for the source code.</p>
<p><strong>UPDATE</strong></p>
<p>A friend suggested I look at the Flex mx.effects.AnimateProperty to animate the scrollbar for the List.  He pointed to me to a blog post by <a href="http://www.thomasdecaux.net/flex-components/different-scroll-solution-than-classic-flex-scrollbars.html">Thomas Decaux</a>.   I will try to work up an example using his approach to compare the two. </p>
<p>- Mister</p>
<p>
<p><map name='google_ad_map_305_1452acacd61817fb'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/305?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_305_1452acacd61817fb' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=305&amp;url= http%3A%2F%2Fwww.thanksmister.com%2Findex.php%2Farchive%2Fscrolling-list-control-with-tweener%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.thanksmister.com/index.php/archive/scrolling-list-control-with-tweener/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>SuperImage Redux</title>
		<link>http://www.thanksmister.com/index.php/archive/superimage-redux/</link>
		<comments>http://www.thanksmister.com/index.php/archive/superimage-redux/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 01:20:12 +0000</pubDate>
		<dc:creator>Mister</dc:creator>
				<category><![CDATA[API]]></category>
		<category><![CDATA[Component]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Flickr]]></category>
		<category><![CDATA[Image]]></category>
		<category><![CDATA[List]]></category>

		<guid isPermaLink="false">http://thanksmister.com/?p=265</guid>
		<description><![CDATA[I have been meaning for so long to post this code. Some time ago I had the pleasure of working with John Yanarella from Universal Mind. John was helping my employer at the time to put together an application that allows users to upload, manage, and share media assets. We needed an efficient way to [...]]]></description>
			<content:encoded><![CDATA[<p>I have been meaning for so long to post this code.  Some time ago I had the pleasure of working with John Yanarella from <a href="http://universalmind.com/">Universal Mind</a>.  John was helping my employer at the time to put together an application that allows users to upload, manage, and share media assets.   We needed an efficient way to cache and display images to optimize the performance of loading and viewing a large number of thumbnails.  </p>
<p><strong>SuperImage</strong></p>
<p>Last year Ely Greenfield posted on his blog <a href="http://www.quietlyscheming.com/blog/">QuietlyScheming</a> a way to end images from flickering when you display them in a Flex List control.   Ely created a new component called <a href="http://www.quietlyscheming.com/blog/2007/01/23/some-thoughts-on-doubt-on-flex-as-the-best-option-orhow-i-made-my-flex-images-stop-dancing/">SuperImage</a> that replaces the Flex Image control.  SuperImage fixes a few issues with the current Image control layout in addition to adding the ability to cache loaded images to stop them from constantly reloading (causing the flicker when scrolling a list).    </p>
<p><strong>SuperImage Update</strong></p>
<p>In our project we wanted use SuperImage, but what we wanted was for SuperImage to behave more like the Flex Image control. Specifically we wanted the control to broadcast the same standard events as the Image control; ioError, securityError, imageComplete, progress, completem, completeEffect.  The new SuperImage also implements IDataRenderer, IDropInListItemRenderer, and IListItemRenderer interfaces.   John Yanarella did a great job cleaning up the SuperImage control and add the missing functionality.  We ended up not using the SuperImage and instead used a simpler implementation for caching the Image control.</p>
<p><span id="more-265"></span></p>
<p><strong>Example</strong></p>
<p>Below is an example similar to <a href="http://www.quietlyscheming.com/blog/2007/01/23/some-thoughts-on-doubt-on-flex-as-the-best-option-orhow-i-made-my-flex-images-stop-dancing/">Ely&#8217;s SuperImage</a> that demonstrates the problem (on the left) with the Image control and the fix (on right) using the updated SuperImage.   This example also shows a text dump of events broadcast from the new SuperImage control.</p>
<div id="flexapp">
        <object type="application/x-shockwave-flash" id="superimage" data= "http://thanksmister.com/examples/superimage/superimageredux.swf" width="640" height="540"><param name="movie" value= "http://thanksmister.com/examples/superimage/superimageredux.swf" /><param name="allowScriptAccess" value="always" /><param name="wmode" value="transparent" /></object>
</div>
<p><strong>Limitations</strong></p>
<p>One thing the updated SuperImage still lacks is the ability to display loaded SWF files.  Since our company never used the code in any project and it was based on Ely&#8217;s code, I thought it only fair to repost the update and the code for everyone to use as needed.   If anyone has an further updates to the code or suggestions to fix the SWF loading issue, please post them here and I will continue to update the component.   </p>
<p><strong>Code</strong></p>
<p>You can download the code for the above project <a href="http://thanksmister.com/examples/superimage/superimageredux.zip">here</a>.  You will need your own <a href="http://www.flickr.com/services/">Flickr API</a> key to make the application work.   Be sure to also read Ely&#8217;s original <a href="http://www.quietlyscheming.com/blog/2007/01/23/some-thoughts-on-doubt-on-flex-as-the-best-option-orhow-i-made-my-flex-images-stop-dancing/">post</a> to see the other benefits of SuperImage.  Many thanks to John Yanarella who actually did the coding on the project, I finally posted it as I promised him many months ago <img src='http://www.thanksmister.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>-Mister</p>
<p><map name='google_ad_map_265_1452acacd61817fb'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/265?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_265_1452acacd61817fb' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=265&amp;url= http%3A%2F%2Fwww.thanksmister.com%2Findex.php%2Farchive%2Fsuperimage-redux%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.thanksmister.com/index.php/archive/superimage-redux/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Custom RichTextEditor</title>
		<link>http://www.thanksmister.com/index.php/archive/custom-richtexteditor/</link>
		<comments>http://www.thanksmister.com/index.php/archive/custom-richtexteditor/#comments</comments>
		<pubDate>Thu, 24 Apr 2008 23:18:08 +0000</pubDate>
		<dc:creator>Mister</dc:creator>
				<category><![CDATA[Component]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[RichTextEditor]]></category>

		<guid isPermaLink="false">http://thanksmister.com/?p=88</guid>
		<description><![CDATA[One of the longest running post on my blog has been about creating XHTML output from the Flex RichTextEditor control. I always thought it would would be nice if someone took all the comments and suggestions for that post and created a customized control that outputs proper XTHML. Well, Axel Jenson has created such a [...]]]></description>
			<content:encoded><![CDATA[<p>One of the longest running <a href="http://thanksmister.com/?p=17">post on my blog</a> has been about creating XHTML output from the Flex RichTextEditor control.  I always thought it would would be nice if someone took all the comments and suggestions for that post and created a customized control that outputs proper XTHML.   Well, <a href="http://www.axelscript.com/2008/03/24/customrichtexteditor-with-xhtml-text/">Axel Jenson</a> has created such a custom control.   I want to send many thanks to all those who posted over the past year and to Axel for stepping up and creating this custom control for Flex.  Give the component a try and let Axel know what you think. </p>
<p>-Mr</p>
<p><map name='google_ad_map_88_1452acacd61817fb'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/88?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_88_1452acacd61817fb' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=88&amp;url= http%3A%2F%2Fwww.thanksmister.com%2Findex.php%2Farchive%2Fcustom-richtexteditor%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.thanksmister.com/index.php/archive/custom-richtexteditor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Error #2025 &#8211; Clash between Flex 2 &amp; Flash CS3</title>
		<link>http://www.thanksmister.com/index.php/archive/error-2025-clash-between-flex-2-flash-cs3/</link>
		<comments>http://www.thanksmister.com/index.php/archive/error-2025-clash-between-flex-2-flash-cs3/#comments</comments>
		<pubDate>Tue, 26 Jun 2007 14:50:13 +0000</pubDate>
		<dc:creator>Mister</dc:creator>
				<category><![CDATA[Component]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://thanksmister.com/?p=64</guid>
		<description><![CDATA[I got my new copy of Flash CS3 and proceeded to make a new preloader for my Flex application.&#160; I made a document Class for my CS3 file and attached a CS3&#160;ProgressBar component.&#160; I had a public function in the Document Class for setting the progress of the Flex preloading.&#160;&#160; I dropped the SWF file [...]]]></description>
			<content:encoded><![CDATA[<p>I got my new copy of Flash CS3 and proceeded to make a new preloader for my Flex application.&nbsp; I made a document Class for my CS3 file and attached a CS3&nbsp;ProgressBar component.&nbsp; I had a public function in the Document Class for setting the progress of the Flex preloading.&nbsp;&nbsp; I dropped the SWF file into my Flex document and set up all the preloading code.&nbsp; If you set&nbsp;a preloader in Flex it will load that file in the first frame before it loads the rest of the Flex application.&nbsp; You can do progressive preloading the same way you would in Flash.&nbsp;&nbsp; The CS3 preloader worked like a charm because with CS3, I can now (though still not elegantly) talk to the functions inside the loaded SWF file.&nbsp;&nbsp; Here is the CS3 Document Class code:</p>
<div class="codecolorer-container actionscript mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:640px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br /></div></td><td><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">package com.<span style="color: #006600;">preloader</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #0066CC;">MovieClip</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> fl.<span style="color: #006600;">controls</span>.<span style="color: #006600;">ProgressBar</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> fl.<span style="color: #006600;">controls</span>.<span style="color: #006600;">ProgressBarMode</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> WelcomeScreenClass <span style="color: #0066CC;">extends</span> flash.<span style="color: #006600;">display</span>.<span style="color: #0066CC;">MovieClip</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> progressBar:ProgressBar;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> WelcomeScreenClass<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; progressBar = <span style="color: #000000; font-weight: bold;">new</span> ProgressBar<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; progressBar.<span style="color: #006600;">indeterminate</span> = <span style="color: #000000; font-weight: bold;">false</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; progressBar.<span style="color: #006600;">mode</span> = ProgressBarMode.<span style="color: #006600;">MANUAL</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; progressBar.<span style="color: #006600;">setSize</span><span style="color: #66cc66;">&#40;</span>150, 22<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; progressBar.<span style="color: #006600;">move</span><span style="color: #66cc66;">&#40;</span>10, 50<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; progressBar.<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;barPadding&quot;</span>, 3<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; progressBar.<span style="color: #006600;">setProgress</span><span style="color: #66cc66;">&#40;</span>50, 100<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addChild<span style="color: #66cc66;">&#40;</span>progressBar<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setLoaderProgress<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">loaded</span>:<span style="color: #0066CC;">Number</span>, total:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; progressBar.<span style="color: #006600;">setProgress</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">loaded</span>, total<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;loaded: &quot;</span> + <span style="color: #0066CC;">loaded</span> + <span style="color: #ff0000;">&quot; of total: &quot;</span> + total<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div></td></tr></tbody></table></div>
<p>This all sounds good so far, a decent marriage between Flash and Flex, weeee!!&nbsp;&nbsp; About a week later I noticed a bug in my Flex application.&nbsp; Every time you hit the Tab key on any dialog created with the PopUpManager or even the Alert, I would get the following error code:</p>
<div class="codecolorer-container actionscript mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ArgumentError: <span style="color: #0066CC;">Error</span> <span style="color: #808080; font-style: italic;">#2025: The supplied DisplayObject must be a child of the caller.</span><br />
&nbsp;at flash.<span style="color: #006600;">display</span>::DisplayObjectContainer<span style="color: #66cc66;">/</span>getChildIndex<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp;at mx.<span style="color: #006600;">core</span>::Container<span style="color: #66cc66;">/</span>getChildIndex<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp;at mx.<span style="color: #006600;">containers</span>::Panel<span style="color: #66cc66;">/</span>getChildIndex<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp;at fl.<span style="color: #006600;">managers</span>::FocusManager<span style="color: #66cc66;">/</span>::getChildIndex<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp;at fl.<span style="color: #006600;">managers</span>::FocusManager<span style="color: #66cc66;">/</span>::sortByDepth<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp;at fl.<span style="color: #006600;">managers</span>::FocusManager<span style="color: #66cc66;">/</span>::sortByTabIndex<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp;at <span style="color: #0066CC;">Array</span>$<span style="color: #66cc66;">/</span><span style="color: #0066CC;">Array</span>::_sort<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp;at <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">/</span>http:<span style="color: #808080; font-style: italic;">//adobe.com/AS3/2006/builtin::sort()</span><br />
&nbsp;at fl.<span style="color: #006600;">managers</span>::FocusManager<span style="color: #66cc66;">/</span>::sortFocusableObjectsTabIndex<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp;at fl.<span style="color: #006600;">managers</span>::FocusManager<span style="color: #66cc66;">/</span>::sortFocusableObjects<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp;at fl.<span style="color: #006600;">managers</span>::FocusManager<span style="color: #66cc66;">/</span>::keyDownHandler<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div></td></tr></tbody></table></div>
<p>This particular bug is very vague and a search of the Internet yielded nothing that seem to fit my situation.&nbsp; I am using Cairngorm with Modules and my suspicion was that I had created a shared code typology.&nbsp;&nbsp; Modules are cool because they can reduce your initial application load, but they are a real pain in the ass to manage because you run into these strange bugs that always seem related to a race condition with loading one Class or Manager into one module.&nbsp;&nbsp;&nbsp; I spent a few days tracking down this issue, testing each module, commenting out code.&nbsp; I finally created a new project without any modules, determined that it was the shared code typology issue.&nbsp; I still had the same issue.</p>
<p>Something about the error dawned on me, the &#8220;fl.managers&#8221;.&nbsp;&nbsp; This is a CS3 code package that Flex does not have.&nbsp;&nbsp; I then decided to remove my CS3 prelaoder, and guess what, the bug went away.&nbsp; I had inadvertently created my own bug by using CS3 with the new ProgressBar component.&nbsp; This component most likely extends UIComponent, which contains the FocusManager, and therefore, causes the issue with the FocusManager in Flex.&nbsp; According to shared code typology 101, the first instance of the loaded manager wins.</p>
<p>The solution was to yank out the CS3&nbsp;ProgressBar component and just create my own progress bar using the Flash drawing tools.&nbsp;&nbsp; This was a tough error, and probably not the first one that will be encountered as Flash and Flex start mingling more in the near future.&nbsp;&nbsp; </p>
<p>-mr</p>
<p><map name='google_ad_map_64_1452acacd61817fb'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/64?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_64_1452acacd61817fb' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=64&amp;url= http%3A%2F%2Fwww.thanksmister.com%2Findex.php%2Farchive%2Ferror-2025-clash-between-flex-2-flash-cs3%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.thanksmister.com/index.php/archive/error-2025-clash-between-flex-2-flash-cs3/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Flex List Control with Editable InputText ItemRenderer</title>
		<link>http://www.thanksmister.com/index.php/archive/flex-list-control-with-with-editable-itemrenderer-inputtext/</link>
		<comments>http://www.thanksmister.com/index.php/archive/flex-list-control-with-with-editable-itemrenderer-inputtext/#comments</comments>
		<pubDate>Wed, 13 Jun 2007 15:52:04 +0000</pubDate>
		<dc:creator>Mister</dc:creator>
				<category><![CDATA[Component]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[InputText]]></category>
		<category><![CDATA[ItemRenderer]]></category>
		<category><![CDATA[List]]></category>
		<category><![CDATA[TileList]]></category>

		<guid isPermaLink="false">http://thanksmister.com/?p=63</guid>
		<description><![CDATA[I think the title of this post says it all.&#160;&#160; I needed a InputText for the label of images in my TitleList control.&#160; I wanted users to click on the text and edit it in place.&#160; I started out creating a simple ItemRenderer with a InputText and skinned the InputText to look like a regular [...]]]></description>
			<content:encoded><![CDATA[<p>I think the title of this post says it all.&nbsp;&nbsp; I needed a InputText for the label of images in my TitleList control.&nbsp; I wanted users to click on the text and edit it in place.&nbsp; I started out creating a simple ItemRenderer with a InputText and skinned the InputText to look like a regular label until you click to edit the information.&nbsp;&nbsp; I then decided to go a little further and make a custom control based on InputText which did all the style changes and kept broadcast a change event only when the text actually changes.&nbsp;&nbsp; I also removed the extension from any titles (like myimage.jpg becomes myimage instead). </p>
<p>This was all fine and dandy until I used the component within the TileList.&nbsp;&nbsp; You see, the List controls allow <a href="http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&amp;file=dpcontrols_062_06.html" target="_blank">Alphanumeric keys</a> as a form of navigation.&nbsp; This is really cool because if you have images and titles below them, you can skip from image to image by typing the first letter of the image title.&nbsp; However, this conflicted with the InputText.&nbsp; Each time I clicked on a title to edit and started to type, the TitleList would navigate based on the character I typed.&nbsp;&nbsp; This was not so cool.&nbsp; </p>
<p>I ended up with a simple solution: </p>
<blockquote><p>event.stopImmediatePropagation();  </p>
</blockquote>
<p>I used stopImmediatePropogation to prevent my keyDown events on the InputText from bubbling up to the List control.&nbsp; Problem solved!&nbsp; Here is a working example, right-click on the Flex application to get the code (I can&#8217;t tell you how many people post messages about how to get the Flex source code from examples, I mean, if you have to ask&#8230;.).</p>
<p>&nbsp;</p>
<p><a href="http://thanksmister.com/examples/itemrenderereditor/Main.html">ItemRendererEditor Example and Source</a></p>
<p>&nbsp;</p>
<p>- Mister</p>
<p><map name='google_ad_map_63_1452acacd61817fb'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/63?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_63_1452acacd61817fb' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=63&amp;url= http%3A%2F%2Fwww.thanksmister.com%2Findex.php%2Farchive%2Fflex-list-control-with-with-editable-itemrenderer-inputtext%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.thanksmister.com/index.php/archive/flex-list-control-with-with-editable-itemrenderer-inputtext/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
