<?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>Saturnboy &#187; gtween</title>
	<atom:link href="http://saturnboy.com/tag/gtween/feed/" rel="self" type="application/rss+xml" />
	<link>http://saturnboy.com</link>
	<description>Code, Work, and Life</description>
	<lastBuildDate>Wed, 28 Jul 2010 13:20:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>GTween, Easing, and Flex 4</title>
		<link>http://saturnboy.com/2009/12/gtween-easing-flex-4/</link>
		<comments>http://saturnboy.com/2009/12/gtween-easing-flex-4/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 02:17:18 +0000</pubDate>
		<dc:creator>justin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[flex4]]></category>
		<category><![CDATA[gtween]]></category>

		<guid isPermaLink="false">http://saturnboy.com/?p=838</guid>
		<description><![CDATA[Recently, I needed to do some programmatic animation in Flex for a client project. I was looking to achieve a kind of &#8220;mouse following&#8221; effect where an object would move towards the mouse even as the mouse itself was moved. And since Grant Skinner just updated his tiny GTween tweening engine, I thought I&#8217;d give [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I needed to do some programmatic animation in Flex for a client project.  I was looking to achieve a kind of &#8220;mouse following&#8221; effect where an object would move towards the mouse even as the mouse itself was moved.  And since Grant Skinner just <a href="http://www.gskinner.com/blog/archives/2009/12/gtween_v201_rel.html">updated</a> his tiny <a href="http://www.gskinner.com/libraries/gtween/">GTween</a> tweening engine, I thought I&#8217;d give it a whirl in Flex 4.</p>
<p class="bottom">Here is the result (view source enabled):</p>
<div id="flashcontent-bar-tween">
Flash is required.  <a href="http://www.adobe.com/go/getflashplayer">Get it here!</a>
</div>
<p>Click and drag the slider up and down to see the &#8220;following&#8221; effect.  The height of each bar is always being tweened to match the target height set by the slider, and each bar moves with a different easing.  Depending on the type of easing, the bars do a better or worse job of following the slider.  In the code, all the magic happens via GTween&#8217;s <code>proxy</code> object, which allows me to adjust the <i>target</i> height of the bar even if the bar is already in motion.</p>
<p class="bottom">Here is the relevant section of code:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> slideHandler<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #b1b100;">for</span> each <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> tween:GTween <span style="color: #b1b100;">in</span> _tweens<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        tween.<span style="color: #006600;">proxy</span>.<span style="color: #006600;">barHeight</span> = slide.<span style="color: #006600;">value</span>;
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>The <code>slideHandler()</code> is called whenever the slider is moved.  Looping through each bar, I simply set the target <code>barHeight</code> via the <code>proxy</code> object and GTween does all the work.  In the end, I get exactly the animation effect I want with a minimum of effort.  I love lazy.  Thanks Grant!</p>
<h5>Files</h5>
<ul>
<li><a href="http://saturnboy.com/proj/flex4/bar_tween/BarTween.html">BarTween</a> (<a href="http://saturnboy.com/proj/flex4/bar_tween/srcview/BarTween.zip">download</a>)</li>
</ul>
<div>
<script type="text/javascript">
swfobject.embedSWF('http://saturnboy.com/proj/flex4/bar_tween/BarTween.swf', 'flashcontent-bar-tween', '440', '430', '10.0.0', 'playerProductInstall.swf', false, { bgColor:'#dddddd', base:'.' });
</script>
</div>
]]></content:encoded>
			<wfw:commentRss>http://saturnboy.com/2009/12/gtween-easing-flex-4/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
