<?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>Bagonca &#187; DragScrollingCanvas</title>
	<atom:link href="http://www.bagonca.com/blog/tag/dragscrollingcanvas/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bagonca.com/blog</link>
	<description>Yet another developer blog</description>
	<lastBuildDate>Fri, 18 Jun 2010 09:28:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>DragScrollingCanvas &#8211; from the wonderful flexlib</title>
		<link>http://www.bagonca.com/blog/2009/03/31/dragscrollingcanvas_-_from_the_wonderful_flexlib/</link>
		<comments>http://www.bagonca.com/blog/2009/03/31/dragscrollingcanvas_-_from_the_wonderful_flexlib/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 13:51:47 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Flex/AS]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[DragScrollingCanvas]]></category>
		<category><![CDATA[Flex and ActionScript]]></category>
		<category><![CDATA[flexlib]]></category>
		<category><![CDATA[projectplace]]></category>

		<guid isPermaLink="false">http://www.bagonca.com/blog/?p=1</guid>
		<description><![CDATA[Modding of DragScrollingCanvas to allow floating of components.]]></description>
			<content:encoded><![CDATA[<p>At Projectplace we are currently in the process of developing an exiting thing: a fast and easy to use planning tool (working name: Yap)! You can read more about that at <a href="http://www.projectplacelabs.com" target="_blank">Projectplace Labs</a>.</p>
<p>The reason for this little post however  is to promote the open source project <a href="http://code.google.com/p/flexlib/" target="_blank">flexlib</a> and more specifically a component contained therein, the DragScrollingCanvas. <a href="http://www.bradrice.com/drupal/flexScrollingCanvas" target="_blank">Brad Rice covers the basics of this component</a>.</p>
<p>We&#8217;ve had much use of this little component in our early development of our timeline view, and whatever your Flex needs might be, you are sure to find tons of helpful components in flexlib.</p>
<p>One thing that we were lacking was the ability to make some components contained in a DragScrollingCanvas move together with the view port. Basically, we wanted a few components to be able to &#8220;float&#8221; on top of the Canvas, keeping its relative position at all times. We solved this by dispatching an event from within the DragScrollingCanvas itself. So, first we typed up a little Event (the below event only allows relative positioning vertically).</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> com.projectplace.<span style="color: #004993;">graphics</span>.events
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">Event</span>;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> DragScrollEvent extends <span style="color: #004993;">Event</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> static const DRAGSCROLLED<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #990000;">&quot;dragscrolled&quot;</span>;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> _y<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> DragScrollEvent<span style="color: #000000;">&#40;</span><span style="color: #004993;">type</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span>, <span style="color: #004993;">y</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">type</span>, <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #0033ff; font-weight: bold;">this</span>._y = <span style="color: #004993;">y</span>;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

</blockquote>
<p>and within DragScrollingCanvas we dispatched this event as soon as some scrolling occured, in the <code>systemManager_mouseMoveHandler</code> function. Last in this function we added:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #004993;">dispatchEvent</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> DragScrollEvent<span style="color: #000000;">&#40;</span>DragScrollEvent.DRAGSCROLLED, <span style="color: #0033ff; font-weight: bold;">this</span>.verticalScrollPosition<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</pre></div></div>

<p>This allowed us to be able to listen for the event in the application, and move whatever component within the canvas to a new position on the canvas, while the user is scrolling. If you&#8217;re crafty you can easily expand this functionality to the horizontal axis as well. Anyway, this is the result, so far. Notice how the date bar on top, follows your scrolling vertically <img src='http://www.bagonca.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><iframe src="http://www.bagonca.com/yap/" width="570" height="500"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bagonca.com/blog/2009/03/31/dragscrollingcanvas_-_from_the_wonderful_flexlib/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
