<?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>Kalen Gibbons &#187; verticalScrollPosition</title>
	<atom:link href="http://www.kalengibbons.com/blog/index.php/tag/verticalscrollposition/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kalengibbons.com/blog</link>
	<description>The Dead Tree Blog</description>
	<lastBuildDate>Mon, 24 Oct 2011 20:43:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Creating a scroll-to list in Flex</title>
		<link>http://www.kalengibbons.com/blog/index.php/2009/06/creating-a-scroll-to-list-in-flex/</link>
		<comments>http://www.kalengibbons.com/blog/index.php/2009/06/creating-a-scroll-to-list-in-flex/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 20:31:25 +0000</pubDate>
		<dc:creator>Kalen Gibbons</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[AnimatedProperty]]></category>
		<category><![CDATA[easingFunction]]></category>
		<category><![CDATA[verticalScrollPosition]]></category>

		<guid isPermaLink="false">http://www.kalengibbons.com/blog/?p=273</guid>
		<description><![CDATA[Here is an example of how you can create a scroll-to list using the AnimateProperty class. In this example I&#8217;m using a repeater instead of a List for simplicity, but for large data sets this would not be recommended. I have a DataGrid on the left hand side that simply lists the release date and [...]]]></description>
			<content:encoded><![CDATA[<p>Here is an example of how you can create a scroll-to list using the <a href="http://livedocs.adobe.com/flex/3/langref/mx/effects/AnimateProperty.html" target="_blank">AnimateProperty</a> class.  In this example I&#8217;m using a repeater instead of a List for simplicity, but for large data sets this would not be recommended.</p>
<p>I have a DataGrid on the left hand side that simply lists the release date and title of several upcoming movie releases.  If you click on a row, the list on the right will scroll to the details for the movie selected.</p>
<p><a href="http://www.kalengibbons.com/assets/pages/srcview/scrollToList/index.html" target="_blank">&#8211; View application source &#8211;</a><br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_scrolltolist_1102086410"
			class="flashmovie"
			width="750"
			height="400">
	<param name="movie" value="/assets/flash/scrolltolist.swf" />
	<param name="bgcolor" value="#000000" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/assets/flash/scrolltolist.swf"
			name="fm_scrolltolist_1102086410"
			width="750"
			height="400">
		<param name="bgcolor" value="#000000" />
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>The code is pretty straightforward, but there two main pieces to look at.  The first is how to use the AnimateProperty class to scroll the list to the desired location. The second, is how to allow the last item in the list to scroll all the way to the top.</p>
<h3>Scrolling to an item in the list</h3>
<div class="code">
<span class="asReserved">import</span> mx.effects.easing.Sine;<br />
<span class="asReserved">import</span> mx.effects.AnimateProperty;<br />
<span class="asReserved">import</span> mx.events.ListEvent;<br />
&nbsp;<br />
<span class="asReserved">private</span> <span class="asVar">var</span> scrollAnimation:AnimateProperty = <span class="asReserved">new</span> AnimateProperty();<br />
&nbsp;<br />
<span class="asReserved">private</span> <span class="asFunction">function</span> scrollToMovie(event:ListEvent):y{</p>
<div class="indent"><span class="asVar">var</span> yPosition:int = movieWrapper.getChildAt(event.rowIndex).y;<br />
scrollAnimation.stop();<br />
scrollAnimation.property = &quot;verticalScrollPosition&quot;;<br />
scrollAnimation.easingFunction = Sine.easeOut;<br />
scrollAnimation.duration = 900;<br />
scrollAnimation.toValue = yPosition;<br />
scrollAnimation.play([movieWrapper]);</div>
<p>}</p></div>
<h3>Allowing the last list item to scroll to the top</h3>
<div class="code">
<span class="asReserved">private</span> <span class="asFunction">function</span> addSpaceToBottom():<span class="asReserved">void</span>{</p>
<div class="indent">
<span class="asReserved">if</span>(movieWrapper.numChildren &gt; 2){</p>
<div class="indent">
<span class="asVar">var</span> lastChild:HBox = movieWrapper.getChildAt(movieWrapper.numChildren-2) <span class="asReserved">as</span> HBox;<br />
<span class="asVar">var</span> spacerHeight:int = movieWrapper.height &#8211; lastChild.height;<br />
<span class="asReserved">if</span>(spacerHeight &gt; 0)</p>
<div class="indent">spacerBottom.height = spacerHeight;</div>
</div>
<p>}</p></div>
<p>}
</p></div>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kalengibbons.com/blog/index.php/2009/06/creating-a-scroll-to-list-in-flex/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

