<?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>Easy Flex</title>
	<atom:link href="http://evtimmy.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://evtimmy.com</link>
	<description>Evtim on Flex SDK</description>
	<lastBuildDate>Thu, 03 Nov 2011 07:18:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Slides for the &#8220;Performance-Tuning Mobile Flex Applications&#8221;, MAX 2011</title>
		<link>http://evtimmy.com/2011/10/424/</link>
		<comments>http://evtimmy.com/2011/10/424/#comments</comments>
		<pubDate>Wed, 05 Oct 2011 20:08:54 +0000</pubDate>
		<dc:creator>Evtim</dc:creator>
				<category><![CDATA[Performance]]></category>
		<category><![CDATA[Session / Talk]]></category>
		<category><![CDATA[Session]]></category>

		<guid isPermaLink="false">http://evtimmy.com/?p=424</guid>
		<description><![CDATA[Update: The link to the recording on Adobe TV is here http://tv.adobe.com/watch/max-2011-develop/performancetuning-mobile-flex-applications/. Here are the slides from our talk we had yesterday and Adobe MAX 2011. Grab the .pptx here: Adobe-MAX2011-Performance-Tuning-Flex-Mobile-Apps Cheers!]]></description>
			<content:encoded><![CDATA[<p><a href="http://evtimmy.com/wordpress/wp-content/uploads/2011/10/Adobe-MAX2011-Performance-Tuning-Flex-Mobile-Apps.pptx"><img class="alignleft size-medium wp-image-428" title="mobile-tuning" src="http://evtimmy.com/wordpress/wp-content/uploads/2011/10/mobile-tuning1-300x223.png" alt="" width="300" height="223" /> </a>Update: The link to the recording on Adobe TV is here <a href="http://tv.adobe.com/watch/max-2011-develop/performancetuning-mobile-flex-applications/">http://tv.adobe.com/watch/max-2011-develop/performancetuning-mobile-flex-applications/</a>. Here are the slides from our talk we had yesterday and Adobe MAX 2011.</p>
<p>Grab the .pptx here:<a href="http://evtimmy.com/wordpress/wp-content/uploads/2011/10/Adobe-MAX2011-Performance-Tuning-Flex-Mobile-Apps.pptx"> Adobe-MAX2011-Performance-Tuning-Flex-Mobile-Apps</a></p>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://evtimmy.com/2011/10/424/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Tired of Typing? No More left=&#8221;0&#8243; right=&#8221;0&#8243; top=&#8221;0&#8243; bottom=&#8221;0&#8243;</title>
		<link>http://evtimmy.com/2011/08/tired-of-typing-no-more-left0-right0-top0-bottom0/</link>
		<comments>http://evtimmy.com/2011/08/tired-of-typing-no-more-left0-right0-top0-bottom0/#comments</comments>
		<pubDate>Tue, 16 Aug 2011 03:23:53 +0000</pubDate>
		<dc:creator>Evtim</dc:creator>
				<category><![CDATA[Flash Builder]]></category>
		<category><![CDATA[Productivity Tips]]></category>

		<guid isPermaLink="false">http://evtimmy.com/?p=398</guid>
		<description><![CDATA[I often find myself typing the same old snipped of MXML code over and over again.  Useful nevertheless, I&#8217;m getting tired it!  If you are like me, it&#8217;s time to automate this.  Fortunately  Flash Builder code templates feature is the perfect solution!  Jump after the break to see my new love in action. &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://evtimmy.com/wordpress/wp-content/uploads/2011/08/Screen-shot-2011-08-15-at-7.46.46-PM.png"><img class="alignleft size-thumbnail wp-image-399" title="Screen shot 2011-08-15 at 7.46.46 PM" src="http://evtimmy.com/wordpress/wp-content/uploads/2011/08/Screen-shot-2011-08-15-at-7.46.46-PM-150x150.png" alt="" width="150" height="150" /></a>I often find myself typing the same old snipped of MXML code over and over again.  Useful nevertheless, I&#8217;m getting tired it!  If you are like me, it&#8217;s time to automate this.  Fortunately  Flash Builder code templates feature is the perfect solution!  Jump after the break to see my new love in action.<span id="more-398"></span></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>This is how I created my new favorite template:</p>
<ol>
<li>Go to FlashBuilder -&gt; Preferences -&gt; Flash Builder -&gt; Editors -&gt; Code Templates -&gt; MXML</li>
<li>Click new template</li>
<li>Type &#8220;left&#8221; for the name</li>
<li>Select &#8220;MXML attributes&#8221; from the Context drop-down</li>
<li>Fill in suitable description</li>
<li>Paste the template body:

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">left=&quot;${values}&quot; right=&quot;${values}&quot; top=&quot;${values}&quot; bottom=&quot;${values}&quot; ${cursor}</pre></div></div>

</li>
<li>Hit &#8220;Apply&#8221; and close the dialog</li>
</ol>
<p>&nbsp;</p>
<p>Now I&#8217;m ready to use it &#8211; I start typing &#8220;left&#8221; and hit the ^space to bring up the suggestions&#8230;</p>
<p><a href="http://evtimmy.com/wordpress/wp-content/uploads/2011/08/Screen-shot-2011-08-15-at-8.06.48-PM.png"><img class="size-full wp-image-405 alignnone" title="Screen shot 2011-08-15 at 8.06.48 PM" src="http://evtimmy.com/wordpress/wp-content/uploads/2011/08/Screen-shot-2011-08-15-at-8.06.48-PM.png" alt="" width="690" height="247" /></a></p>
<p>&nbsp;</p>
<p>&#8230;then I select my template and Flash Builder inserts the body and places my cursor on the first field&#8230;</p>
<p><a href="http://evtimmy.com/wordpress/wp-content/uploads/2011/08/Screen-shot-2011-08-15-at-8.07.33-PM.png"><img class="size-full wp-image-406 alignnone" title="Screen shot 2011-08-15 at 8.07.33 PM" src="http://evtimmy.com/wordpress/wp-content/uploads/2011/08/Screen-shot-2011-08-15-at-8.07.33-PM.png" alt="" width="690" height="247" /></a></p>
<p>&nbsp;</p>
<p>&#8230;I enter the value &#8211; in this case a single &#8220;0&#8243; and Flash Builder fills in the values for all four attributes!</p>
<p><a href="http://evtimmy.com/wordpress/wp-content/uploads/2011/08/Screen-shot-2011-08-15-at-8.07.59-PM.png"><img class="size-full wp-image-407 alignnone" title="Screen shot 2011-08-15 at 8.07.59 PM" src="http://evtimmy.com/wordpress/wp-content/uploads/2011/08/Screen-shot-2011-08-15-at-8.07.59-PM.png" alt="" width="691" height="247" /></a></p>
<p>&nbsp;</p>
<p>Finally, I press &#8220;tab&#8221; to get to the end of the code snippet and continue with the MXML.</p>
<p>Cheers!</p>
<p>&nbsp;</p>
<p>PS : I looove code templates!  Almost as much as conditional breakpoints!!! <img src='http://evtimmy.com/wordpress/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://evtimmy.com/2011/08/tired-of-typing-no-more-left0-right0-top0-bottom0/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Recording of Flex 360 Denver Performance Talk</title>
		<link>http://evtimmy.com/2011/06/recording-of-flex-360-denver-performance-talk/</link>
		<comments>http://evtimmy.com/2011/06/recording-of-flex-360-denver-performance-talk/#comments</comments>
		<pubDate>Tue, 14 Jun 2011 21:01:26 +0000</pubDate>
		<dc:creator>Evtim</dc:creator>
				<category><![CDATA[Performance]]></category>
		<category><![CDATA[360 Flex]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[ItemRenderer]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Session]]></category>

		<guid isPermaLink="false">http://evtimmy.com/?p=388</guid>
		<description><![CDATA[If you missed our performance talk at Flex 360 Denver, head out to ZaaTV, where it&#8217;s available for free.  Cheers! =) &#160;]]></description>
			<content:encoded><![CDATA[<p><a href="http://zaa.tv/2011/06/360flex-denver-2011-flex-performance-tips-and-tricks/"><img class="alignleft size-thumbnail wp-image-392" title="360flex-perf-tips-QnA" src="http://evtimmy.com/wordpress/wp-content/uploads/2011/06/360flex-perf-tips-QnA-150x150.png" alt="" width="150" height="150" /></a>If you missed our performance talk at Flex 360 Denver, head out to <a title="ZaaTV" href="http://zaa.tv/2011/06/360flex-denver-2011-flex-performance-tips-and-tricks/">ZaaTV</a>, where it&#8217;s available for free.  Cheers! =)</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://evtimmy.com/2011/06/recording-of-flex-360-denver-performance-talk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Slides from &#8220;Flex Performance Tips and Tricks&#8221;</title>
		<link>http://evtimmy.com/2011/04/slides-from-flex-performance-tips-and-tricks/</link>
		<comments>http://evtimmy.com/2011/04/slides-from-flex-performance-tips-and-tricks/#comments</comments>
		<pubDate>Fri, 22 Apr 2011 06:46:02 +0000</pubDate>
		<dc:creator>Evtim</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[360 Flex]]></category>
		<category><![CDATA[Flex 4.5]]></category>
		<category><![CDATA[FXG]]></category>
		<category><![CDATA[ItemRenderer]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Session]]></category>

		<guid isPermaLink="false">http://evtimmy.com/?p=376</guid>
		<description><![CDATA[Just a quick post to point to the slides from our &#8220;Flex Performance Tips and Tricks&#8221; session Steve and I gave at 360 Flex in Denver.  Steve posted the slides here.  My understanding is that the recording will be available at some point.  I&#8217;ll put up a link to it as well when I get [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://flexponential.com/2011/04/20/flex-performance-tips-tricks/"><img class="alignleft size-full wp-image-380" title="slides-flex-tips-and-tricks-thumb" src="http://evtimmy.com/wordpress/wp-content/uploads/2011/04/slides-flex-tips-and-tricks-thumb.jpg" alt="" width="146" height="102" /></a>Just a quick post to point to the slides from our &#8220;Flex Performance Tips and Tricks&#8221; session <a href="http://flexponential.com/">Steve </a>and I gave at <a href="http://www.360flex.com/">360 Flex</a> in Denver.  Steve posted the slides <a href="http://flexponential.com/2011/04/20/flex-performance-tips-tricks/">here</a>.  My understanding is that the recording will be available at some point.  I&#8217;ll put up a link to it as well when I get it =)<a href="http://flexponential.com/2011/04/20/flex-performance-tips-tricks/"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://evtimmy.com/2011/04/slides-from-flex-performance-tips-and-tricks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Two Examples of Layout Animations</title>
		<link>http://evtimmy.com/2010/04/two-examples-of-layout-animations/</link>
		<comments>http://evtimmy.com/2010/04/two-examples-of-layout-animations/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 06:42:10 +0000</pubDate>
		<dc:creator>Evtim</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[Animation]]></category>
		<category><![CDATA[Custom Layout]]></category>
		<category><![CDATA[Spark Layouts]]></category>
		<category><![CDATA[Effects]]></category>
		<category><![CDATA[Layout]]></category>
		<category><![CDATA[Move3D]]></category>
		<category><![CDATA[Rotate3D]]></category>
		<category><![CDATA[Scrolling]]></category>
		<category><![CDATA[Spark]]></category>
		<category><![CDATA[WheelLayout]]></category>

		<guid isPermaLink="false">http://evtimmy.com/?p=318</guid>
		<description><![CDATA[A few folks have been asking for the source of my Creating Custom Layouts in Flex 4 talk at the Flash Camp Boston event, and I finally found the time to post it here. My apologies for the delay. Click on the image to go to the demo, right-click and select &#8220;view source&#8221; to get [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://evtimmy.com/wordpress/wp-content/uploads/2010/04/layout-animation/FlickrRIAModified.swf"><img class="alignleft size-thumbnail wp-image-320" title="layout-animation" src="http://evtimmy.com/wordpress/wp-content/uploads/2010/04/layout-animation-150x150.png" alt="layout-animation" width="150" height="150" /></a> A few folks have been asking for the source of my <a href="http://tv.adobe.com/watch/flash-camp-boston/creating-custom-layouts-in-flex-4-">Creating Custom Layouts in Flex 4</a> talk at the Flash Camp Boston event, and I finally found the time to post it here. My apologies for the delay.  Click on the image to go to the demo, right-click and select &#8220;view source&#8221; to get to the goods. <span id="more-318"></span> This is pretty much my old WheelLayout demo, but I added a couple of animations  to make things a little bit slicker:</p>
<ol>
<li>Clicking on any image in the WheelLayout mode will rotate all the elements until the selected item is centered in front. <em>In this animation the layout runs on every frame of the animation.</em></li>
<li>Selecting different layouts from the drop-down will animate the items&#8217; transformation. <em>In this animation the layout is disabled and is not running during the animation.</em></li>
</ol>
<h3>Animating the Scroll Position</h3>
<p>In the first animation I want the selected item to come &#8220;in view&#8221;. In the <em>WheelLayout</em> I&#8217;ve already implemented the standard API that calculates the scroll distance to an item &#8211; <em>getScrollPositionDeltaToElement()</em>. Now in the item renderer of the list &#8211; <em>FlickrThumbnail.mxml</em> &#8211; I detect when the item has been clicked and then create an animation for the scroll position of the parent <em>Group</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> itemrenderer1_clickHandler<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #6699cc; font-weight: bold;">var</span> g<span style="color: #000066; font-weight: bold;">:</span>GroupBase = <span style="color: #004993;">parent</span> <span style="color: #0033ff; font-weight: bold;">as</span> GroupBase<span style="color: #000066; font-weight: bold;">;</span>
    <span style="color: #6699cc; font-weight: bold;">var</span> p<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Point</span> = g<span style="color: #000066; font-weight: bold;">.</span>layout<span style="color: #000066; font-weight: bold;">.</span>getScrollPositionDeltaToElement<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span>itemIndex<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
    <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>p<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #6699cc; font-weight: bold;">var</span> startX<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = g<span style="color: #000066; font-weight: bold;">.</span>horizontalScrollPosition<span style="color: #000066; font-weight: bold;">;</span>
        <span style="color: #6699cc; font-weight: bold;">var</span> startY<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = g<span style="color: #000066; font-weight: bold;">.</span>verticalScrollPosition<span style="color: #000066; font-weight: bold;">;</span>
        <span style="color: #6699cc; font-weight: bold;">var</span> anim<span style="color: #000066; font-weight: bold;">:</span>Animate = <span style="color: #0033ff; font-weight: bold;">new</span> Animate<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
        anim<span style="color: #000066; font-weight: bold;">.</span>motionPaths = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #000000;">&#91;</span>
            <span style="color: #0033ff; font-weight: bold;">new</span> SimpleMotionPath<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;horizontalScrollPosition&quot;</span><span style="color: #000066; font-weight: bold;">,</span> startX<span style="color: #000066; font-weight: bold;">,</span> startX <span style="color: #000066; font-weight: bold;">+</span> p<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">500</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span>
            <span style="color: #0033ff; font-weight: bold;">new</span> SimpleMotionPath<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;verticalScrollPosition&quot;</span><span style="color: #000066; font-weight: bold;">,</span> startY<span style="color: #000066; font-weight: bold;">,</span> startY <span style="color: #000066; font-weight: bold;">+</span> p<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">500</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
        <span style="color: #6699cc; font-weight: bold;">var</span> interpolator<span style="color: #000066; font-weight: bold;">:</span>NumberInterpolatorWrapping =
			<span style="color: #0033ff; font-weight: bold;">new</span> NumberInterpolatorWrapping<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> g<span style="color: #000066; font-weight: bold;">.</span>contentWidth <span style="color: #000066; font-weight: bold;">-</span> g<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
        <span style="color: #6699cc; font-weight: bold;">var</span> scrollLength<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = interpolator<span style="color: #000066; font-weight: bold;">.</span>getLength<span style="color: #000000;">&#40;</span>startX<span style="color: #000066; font-weight: bold;">,</span> startX <span style="color: #000066; font-weight: bold;">+</span> p<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
        anim<span style="color: #000066; font-weight: bold;">.</span>interpolator = interpolator<span style="color: #000066; font-weight: bold;">;</span>
        anim<span style="color: #000066; font-weight: bold;">.</span>duration = <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">max</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">550</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">min</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">2500</span><span style="color: #000066; font-weight: bold;">,</span> scrollLength <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
        anim<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">play</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span>g<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>One interesting thing to note is that because of the circular nature of the WheelLayout I wanted the animation to interpolate between the values in a wrap-around manner. For example scrolling from the last element to the first element shouldn&#8217;t scroll through any other elements since the first and last elements are visually next to each other. For that reason I implemented a custom interpolator &#8211; <em>NumberInterpolatorWrapping.as</em>.</p>
<h3>Animating Items between Different Layouts</h3>
<p>In this animation I wanted all the elements to move and rotate smoothly when I switch between various layouts. In this animation the start position is defined by the current layout and the end position is defined by the new layout. In-between, while the elements are being animated, they really don&#8217;t belong to any layout. For that reason, I disable the layout of the container for the duration of the animation using the <em>autoLayout </em>property of the parent <em>Group</em>.</p>
<p>For convenience I transition between the layouts using states:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;s:states</span><span style="color: #7400FF;">&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:State</span> name=<span style="color: #ff0000;">&quot;tile&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:State</span> name=<span style="color: #ff0000;">&quot;wheel&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:State</span> name=<span style="color: #ff0000;">&quot;vertical&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:State</span> name=<span style="color: #ff0000;">&quot;horizontal&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:states</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:List</span> width=<span style="color: #ff0000;">&quot;100%&quot;</span> height=<span style="color: #ff0000;">&quot;100%&quot;</span></span>
<span style="color: #000000;">		dataProvider=<span style="color: #ff0000;">&quot;{photoFeed}&quot;</span></span>
<span style="color: #000000;">		itemRenderer=<span style="color: #ff0000;">&quot;FlickrThumbnail&quot;</span></span>
<span style="color: #000000;">		id=<span style="color: #ff0000;">&quot;theList&quot;</span> useVirtualLayout=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:layout</span>.vertical<span style="color: #7400FF;">&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:VerticalLayout</span> horizontalAlign=<span style="color: #ff0000;">&quot;center&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:layout</span>.vertical<span style="color: #7400FF;">&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:layout</span>.horizontal<span style="color: #7400FF;">&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:HorizontalLayout</span> verticalAlign=<span style="color: #ff0000;">&quot;middle&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:layout</span>.horizontal<span style="color: #7400FF;">&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:layout</span>.tile<span style="color: #7400FF;">&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:TileLayout</span> horizontalAlign=<span style="color: #ff0000;">&quot;center&quot;</span> verticalAlign=<span style="color: #ff0000;">&quot;bottom&quot;</span></span>
<span style="color: #000000;">                                      columnWidth=<span style="color: #ff0000;">&quot;112&quot;</span> rowHeight=<span style="color: #ff0000;">&quot;132&quot;</span></span>
<span style="color: #000000;">				      requestedColumnCount=<span style="color: #ff0000;">&quot;5&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:layout</span>.tile<span style="color: #7400FF;">&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:layout</span>.wheel<span style="color: #7400FF;">&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;my:WheelLayout</span> gap=<span style="color: #ff0000;">&quot;20&quot;</span> axisAngle=<span style="color: #ff0000;">&quot;{axisSlider.value}&quot;</span></span>
<span style="color: #000000;">		verticalCenterOffset=<span style="color: #ff0000;">&quot;{offsetSlider.value}&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:layout</span>.wheel<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:List</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>Because the elements could be both moved and/or rotated in 2D or 3D, I use a parallel of both effects:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Parallel</span> id=<span style="color: #ff0000;">&quot;myEffect&quot;</span> effectEnd=<span style="color: #ff0000;">&quot;myEffect_effectEndHandler(event)&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Move</span>3D applyChangesPostLayout=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Rotate</span>3D applyChangesPostLayout=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Parallel</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>And finally, when I switch from one layout state to another, I want to run the effect. Now I need to perform the following steps:</p>
<ol>
<li>Make the effect target all of the elements.</li>
<li>Capture the start values (the position and rotation defined by the old layout).</li>
<li>Switch the layout (by changing the state) and call <em>validateNow()</em> so that all elements are positioned and/or rotated by the new layout.</li>
<li>Turn off the <em>autoLayout</em> property so that the new layout doesn&#8217;t interfere with the running effect.</li>
<li>Run the effect. Note that at this point the effect is going to capture the animation end values &#8211; the position/rotation defined by the new layout. I&#8217;ve already captured the start values at step 2, so I&#8217;m all set.</li>
<li>When the effect is done, turn the layout back on.</li>
</ol>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> animateTo<span style="color: #000000;">&#40;</span>toState<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #009900; font-style: italic;">// Make sure any previous animation is stopped.</span>
    <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>myEffect<span style="color: #000066; font-weight: bold;">.</span>isPlaying<span style="color: #000000;">&#41;</span>
        myEffect<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">stop</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
    <span style="color: #009900; font-style: italic;">// Add targets</span>
    myEffect<span style="color: #000066; font-weight: bold;">.</span>targets = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Array</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
    <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> i <span style="color: #000066; font-weight: bold;">&lt;</span> theList<span style="color: #000066; font-weight: bold;">.</span>dataGroup<span style="color: #000066; font-weight: bold;">.</span>numElements<span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span>
        myEffect<span style="color: #000066; font-weight: bold;">.</span>targets<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span>theList<span style="color: #000066; font-weight: bold;">.</span>dataGroup<span style="color: #000066; font-weight: bold;">.</span>getElementAt<span style="color: #000000;">&#40;</span>i<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
    <span style="color: #009900; font-style: italic;">// Create Transition for all elements</span>
    myEffect<span style="color: #000066; font-weight: bold;">.</span>captureStartValues<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
    <span style="color: #009900; font-style: italic;">// Go to the end state</span>
    <span style="color: #6699cc; font-weight: bold;">var</span> fromState<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span>currentState<span style="color: #000066; font-weight: bold;">;</span>
    setCurrentState<span style="color: #000000;">&#40;</span>toState<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
    <span style="color: #009900; font-style: italic;">// Validate everything before turning off the layout</span>
    theList<span style="color: #000066; font-weight: bold;">.</span>validateNow<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
    <span style="color: #009900; font-style: italic;">// Turn the layout off before running the effect</span>
    theList<span style="color: #000066; font-weight: bold;">.</span>dataGroup<span style="color: #000066; font-weight: bold;">.</span>autoLayout = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
    <span style="color: #009900; font-style: italic;">// Play the effect</span>
    myEffect<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">play</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> myEffect_effectEndHandler<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span>EffectEvent<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
<span style="color: #000000;">&#123;</span>
    theList<span style="color: #000066; font-weight: bold;">.</span>dataGroup<span style="color: #000066; font-weight: bold;">.</span>autoLayout = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Note that my demo has one limitation &#8211; I needed to turn off virtual layout so that everything works fine. If I have virtual layout running, I&#8217;m not guaranteed that the old and new layouts will assign the items to the same item renderers.<br />
Click on the image at the top to go to the demo, where you can select &#8220;view source&#8221; from the right-click menu to get the code.</p>
]]></content:encoded>
			<wfw:commentRss>http://evtimmy.com/2010/04/two-examples-of-layout-animations/feed/</wfw:commentRss>
		<slash:comments>30</slash:comments>
		</item>
		<item>
		<title>Extending HorizontalLayout to Support Baseline (Align to Text)</title>
		<link>http://evtimmy.com/2010/02/extending-horizontallayout-to-support-baseline-align-to-text/</link>
		<comments>http://evtimmy.com/2010/02/extending-horizontallayout-to-support-baseline-align-to-text/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 08:06:42 +0000</pubDate>
		<dc:creator>Evtim</dc:creator>
				<category><![CDATA[Custom Layout]]></category>
		<category><![CDATA[Spark Layouts]]></category>
		<category><![CDATA[align to text]]></category>
		<category><![CDATA[alignment]]></category>
		<category><![CDATA[baseline]]></category>
		<category><![CDATA[Layout]]></category>

		<guid isPermaLink="false">http://evtimmy.com/?p=265</guid>
		<description><![CDATA[The current Spark HorizontalLayout unfortunately doesn&#8217;t support baseline alignment. If I want to have, for example, a Label and a Button positioned so that their text aligns, I usualy use absolute position (nudging things up or down) or baseline constraints with BasicLayout/Canvas. But then again, I always find myself needing this feature in a HorizontalLayout [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://evtimmy.com/wordpress/wp-content/uploads/2010/02/hlayoutbaseline/HLayoutBaseline.swf"><img class="alignleft size-thumbnail wp-image-266" style="margin-left: 10px; margin-right: 10px;" title="hlayoutbaseline" src="http://evtimmy.com/wordpress/wp-content/uploads/2010/02/hlayoutbaseline-150x150.png" alt="hlayoutbaseline" width="150" height="150" /></a>The current Spark <em>HorizontalLayout </em>unfortunately doesn&#8217;t support <em>baseline </em>alignment. If I want to have, for example, a <em>Label </em>and a <em>Button</em> positioned so that their text aligns, I usualy use absolute position (nudging things up or down) or <em>baseline </em>constraints with <em>BasicLayout</em>/<em>Canvas</em>.  But then again, I always find myself needing this feature in a <em>HorizontalLayout </em>and so I finally decided to tackle it on. It turns out it&#8217;s pretty easy to extend the stock Spark <em>HorizontalLayout</em>, not to mention using it is a breeze with the Spark layout architecture (yay Spark!).<span id="more-265"></span></p>
<h3>Baseline Concepts in Flex</h3>
<ul>
<li>Each <em>IVisualElement </em>has a <em>baselinePosition</em>. This is the vertical distance from element&#8217;s top (origin) to its text base.</li>
<li>To align an <em>IVisualElement</em>&#8216;s text to a specific point within its parent, say A=100, we roughly do the following <span style="color: #ff6600;">element.y = A &#8211; element.baselinePosition</span>.</li>
<li>Each IVisualElement has a <em>baseline</em> constraint. How this is going to be used is up to the parent layout. By default <em>BasicLayout</em>/<em>Canvas </em>interpret it as the position within the parent to which the element&#8217;s text base should be aligned, meaning that the actual calculation is <span style="color: #ff6600;">element.y = element.baseline &#8211; element.baselinePosition</span>.</li>
</ul>
<h3>What I Want</h3>
<ol>
<li>Still keep all the cool functionality of the HorizontalLayout without copying code.</li>
<li>Ability to specify a <span style="color: #339966;"><em>global baseline</em></span>. The layout should position all the elements such that their text aligns to that <span style="color: #339966;"><em>global baseline</em></span>. I also want the ability to individually offset the elements from the <em><span style="color: #339966;">global baseline</span></em>. I want the element&#8217;s <em>baseline </em>constraint, if specified, to serve as such an offset.</li>
<li>If I&#8217;m too lazy to specify the <em><span style="color: #339966;">global baseline</span></em>, the layout should calculate it for me. In that case there shouldn&#8217;t be any extra space around the elements and the layout&#8217;s borders.</li>
<li>The <span style="color: #339966;"><em>global baseline</em></span> should be <span style="color: #0000ff;">[Bindable]</span>. Since the layout is calculating it in certain cases, I want to be able to read it back whenever its value changes.</li>
</ol>
<p>Here&#8217;s an example of the layout in action:  <a href="http://evtimmy.com/wordpress/wp-content/uploads/2010/02/hlayoutbaseline-simple.png"><img class="alignleft size-full wp-image-297" title="hlayoutbaseline-simple" src="http://evtimmy.com/wordpress/wp-content/uploads/2010/02/hlayoutbaseline-simple.png" alt="hlayoutbaseline-simple" width="232" height="47" /></a></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Application</span> xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span></span>
<span style="color: #000000;">               xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span></span>
<span style="color: #000000;">               xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/mx&quot;</span></span>
<span style="color: #000000;">               xmlns:local=<span style="color: #ff0000;">&quot;*&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:BorderContainer</span> horizontalCenter=<span style="color: #ff0000;">&quot;0&quot;</span> verticalCenter=<span style="color: #ff0000;">&quot;0&quot;</span></span>
<span style="color: #000000;">                       minWidth=<span style="color: #ff0000;">&quot;0&quot;</span> minHeight=<span style="color: #ff0000;">&quot;0&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:layout</span><span style="color: #7400FF;">&gt;</span></span>
             <span style="color: #000000;"><span style="color: #7400FF;">&lt;local:HBaselineLayout</span> verticalAlign=<span style="color: #ff0000;">&quot;baseline&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:layout</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:CheckBox</span> label=<span style="color: #ff0000;">&quot;hello&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Button</span> label=<span style="color: #ff0000;">&quot;button&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Label</span> text=<span style="color: #ff0000;">&quot;and label&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:BorderContainer</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></td></tr></table></div>

<h3>Implementation</h3>
<ol>
<li>I extended the <em>HorizontalLayout </em>class and had to override the <em>verticalAlign </em>property getter in order to modify the enum metadata and add &#8220;baseline&#8221; as an option.</li>
<li>I added a <span style="color: #339966;"><em>globalBaseline</em> </span>property. I had to override the <em>updateDisplayList()</em> method. After the super.updateDisplayList() has finished with sizing and positioning the elements, I&#8217;d iterate over them and position them using something like this <span style="color: #ff6600;">element.setLayoutBoundsPosition(element.getLayoutBoundsX(), globalBaseline + element.baseline &#8211; element.baselinePosition)</span>.</li>
<li>Calculating the <span style="color: #339966;"><em>globalBaseline </em></span>is easy enough. If all the elements are aligned at the <span style="color: #339966;"><em>globalBaseline</em></span>, then a certain portion of each element will be above that line and the rest will be below the line &#8211; top portion and bottom portion. Then I have <span style="color: #ff6600;">topPortion = element.baseline &#8211; element.baselinePosition</span> and <span style="color: #ff6600;">bottomPortion = element.height &#8211; element.baseline + element.baselinePosition</span>. Now since I don&#8217;t want any extra space around the elements I want the element that sticks out the most above the <span style="color: #339966;"><em>globalBaseline </em></span>to touch the top edge of the container, while the element that sticks out the most below the <span style="color: #339966;"><em>globalBaseline </em></span>to touch the bottom edge of the container. Therefore the <span style="color: #339966;"><em>globalBaseline </em></span>is going to be the maximum of the top portions, while the measured height of the container is going to be the<span style="color: #ff6600;"> <span style="color: #339966;"><em>globalBaseline </em></span></span>+ the maximum of the bottom portions. I created a helper function to calculate the maximums of the top and bottom portions and used it in the overridden <em>measure()</em> and <em>updateDisplayList()</em> methods.</li>
<li>Finally, I added a property <span style="color: #339966;"><em>actualBaseline </em></span>and made sure to dispatch an event when it changes. I update the <em><span style="color: #339966;">actualBaseline </span></em>at the end of <em>updateDisplayList()</em> so that at the time of the event it&#8217;s certain that all elements are already sized and positioned correctly.</li>
</ol>
<p>Here&#8217;s an <a href="http://evtimmy.com/wordpress/wp-content/uploads/2010/02/hlayoutbaseline/HLayoutBaseline.swf">example</a> of a working app, to get the source right-click on the application and select &#8220;view source&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://evtimmy.com/2010/02/extending-horizontallayout-to-support-baseline-align-to-text/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>VerticalAlign for VGroup and HorizontalAlign for HGroup</title>
		<link>http://evtimmy.com/2010/01/verticalalign-for-vgroup-and-horizontalalign-for-hgroup/</link>
		<comments>http://evtimmy.com/2010/01/verticalalign-for-vgroup-and-horizontalalign-for-hgroup/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 02:13:49 +0000</pubDate>
		<dc:creator>Evtim</dc:creator>
				<category><![CDATA[Spark Layouts]]></category>
		<category><![CDATA[alignment]]></category>
		<category><![CDATA[Flex 4]]></category>
		<category><![CDATA[Layout]]></category>
		<category><![CDATA[Scrolling]]></category>
		<category><![CDATA[Spark]]></category>

		<guid isPermaLink="false">http://evtimmy.com/?p=239</guid>
		<description><![CDATA[Recently I checked in the major axis alignment update to VGroup, HGroup, VerticalLayout, HorizontalLayout. It brings parity to the Flex 4 Spark layouts relative to the MX containers HBox and VBox that are well known from previous versions of Flex (and have had those alignment options for long time now). Now VGroup and VerticalLayout have [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://evtimmy.com/wordpress/wp-content/uploads/2010/01/majoraxisalignment.swf"><img class="alignleft size-thumbnail wp-image-240" title="majoraxisalignment" src="http://evtimmy.com/wordpress/wp-content/uploads/2010/01/majoraxisalignment-150x150.png" alt="majoraxisalignment" width="150" height="150" /></a> Recently I checked in the major axis alignment update to <em>VGroup</em>, <em>HGroup</em>, <em>VerticalLayout</em>, <em>HorizontalLayout</em>. It brings parity to the Flex 4 Spark layouts relative to the MX containers <em>HBox</em> and <em>VBox </em>that are well known from previous versions of Flex (and have had those alignment options for long time now). <span id="more-239"></span></p>
<p>Now <em>VGroup </em>and <em>VerticalLayout </em>have a &#8220;<em>verticalAlign</em>&#8221; property with the three supported values of &#8220;<em>top</em>&#8220;, &#8220;<em>middle</em>&#8220;, &#8220;<em>bottom</em>&#8220;.  Accordingly <em>HGroup </em>and <em>HorizontalLayout </em>get a &#8220;<em>horizontalAlign</em>&#8221; property with the supported values of &#8220;<em>left</em>&#8220;, &#8220;<em>center</em>&#8221; and &#8220;<em>right</em>&#8220;.  The alignment modes work for the layouts with and without virtualization enabled.<br />
An important difference to note is that when &#8220;<em>clipAndEnableScrolling</em>&#8221; is set to &#8220;<em>true</em>&#8221; and the containers are scrolling (the content is bigger than the container), the Spark layouts ensure that the entire content can be scrolled in view by internally reverting to the &#8220;<em>top</em>&#8220;/&#8221;<em>left</em>&#8221; alignment respectively.</p>
<p>When playing with the attached sample, you&#8217;ll notice difference between the clipping and the non-clipping containers when scrolling is in effect (drag the slider left to force smaller height for the containers).</p>
<p>The sample was compiled with SDK version 4.0.0.13553, source: <a href="http://evtimmy.com/wordpress/wp-content/uploads/2010/01/majoraxisalignment.mxml">MajorAxisAlignment.mxml</a></p>
]]></content:encoded>
			<wfw:commentRss>http://evtimmy.com/2010/01/verticalalign-for-vgroup-and-horizontalalign-for-hgroup/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Drag and Drop Skinning in Spark</title>
		<link>http://evtimmy.com/2010/01/drag-and-drop-skinning-in-spark/</link>
		<comments>http://evtimmy.com/2010/01/drag-and-drop-skinning-in-spark/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 06:16:04 +0000</pubDate>
		<dc:creator>Evtim</dc:creator>
				<category><![CDATA[drag and drop]]></category>
		<category><![CDATA[skinning]]></category>

		<guid isPermaLink="false">http://evtimmy.com/?p=198</guid>
		<description><![CDATA[Customize the ItemRenderer&#8216;s &#8220;dragging&#8221; state.  The drag indicator is the image that the user sees when they select and item and drag it away from the source container. By default the Spark List creates a drag indicator by duplicating all the ItemRenderers for the items being dragged. Therefore a natural way to customize the drag [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://evtimmy.com/wordpress/wp-content/uploads/2010/01/dndlistskinning.swf"><img class="alignleft size-thumbnail wp-image-199" title="dndlistskinning" src="http://evtimmy.com/wordpress/wp-content/uploads/2010/01/dndlistskinning-150x150.png" alt="dndlistskinning" width="150" height="150" /></a></p>
<p><span style="color: #ff6600;">Customize the <em>ItemRenderer</em>&#8216;s &#8220;<em>dragging</em>&#8221; state</span>.  The <em>drag indicator</em> is the image that the user sees when they select and item and drag it away from the source container. By default the Spark List creates a <em>drag indicator</em> by duplicating all the <em>ItemRenderers </em>for the items being dragged. Therefore a natural way to customize the drag indicator is by customizing the <em>ItemRenderer </em>skin. Spark makes that easy by introducing the  optional &#8220;<em>dragging</em>&#8221; state.<br />
<span style="color: #ff6600;">Customize the <em>List</em>&#8216;s optional &#8220;<em>dropIndicator</em>&#8221; skin part</span>.  The <em>drop indicator</em> is the image that the user sees as an indicator of where the dragged items are going to be inserted in the destination container.  By default, the Spark List displays a horizontal/vertical line along the gap between the at the insertion point.  Spark makes that easy by automatically managing the &#8220;<em>dropIndicator</em>&#8221; optional dynamic skin part.</p>
<p><span id="more-198"></span></p>
<h2>Customize the Drag Indicator</h2>
<p>I&#8217;ll set up a custom ItemRenderer and I&#8217;ll flesh out the optional &#8220;dragging&#8221; state.<br />
CustomDraggingItemRenderer.mxml:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:ItemRenderer</span> focusEnabled=<span style="color: #ff0000;">&quot;false&quot;</span> </span>
<span style="color: #000000;">				xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span> </span>
<span style="color: #000000;">				xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:states</span><span style="color: #7400FF;">&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:State</span> name=<span style="color: #ff0000;">&quot;normal&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>            
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:State</span> name=<span style="color: #ff0000;">&quot;hovered&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:State</span> name=<span style="color: #ff0000;">&quot;selected&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:State</span> name=<span style="color: #ff0000;">&quot;normalAndShowsCaret&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:State</span> name=<span style="color: #ff0000;">&quot;hoveredAndShowsCaret&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:State</span> name=<span style="color: #ff0000;">&quot;selectedAndShowsCaret&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:State</span> name=<span style="color: #ff0000;">&quot;dragging&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:states</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Rect</span> left=<span style="color: #ff0000;">&quot;0&quot;</span> right=<span style="color: #ff0000;">&quot;0&quot;</span> top=<span style="color: #ff0000;">&quot;0&quot;</span> bottom=<span style="color: #ff0000;">&quot;-1&quot;</span> includeIn=<span style="color: #ff0000;">&quot;dragging&quot;</span><span style="color: #7400FF;">&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:stroke</span><span style="color: #7400FF;">&gt;</span></span>
			<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:SolidColorStroke</span> color=<span style="color: #ff0000;">&quot;0xDDBBCC&quot;</span> weight=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:stroke</span><span style="color: #7400FF;">&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:fill</span><span style="color: #7400FF;">&gt;</span></span>
			<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:SolidColor</span> color=<span style="color: #ff0000;">&quot;0x5010CC&quot;</span> alpha=<span style="color: #ff0000;">&quot;0.3&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:fill</span><span style="color: #7400FF;">&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Rect</span><span style="color: #7400FF;">&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Label</span> id=<span style="color: #ff0000;">&quot;labelDisplay&quot;</span> verticalCenter=<span style="color: #ff0000;">&quot;0&quot;</span> </span>
<span style="color: #000000;">			 left=<span style="color: #ff0000;">&quot;3&quot;</span> right=<span style="color: #ff0000;">&quot;3&quot;</span> top=<span style="color: #ff0000;">&quot;6&quot;</span> bottom=<span style="color: #ff0000;">&quot;4&quot;</span> </span>
<span style="color: #000000;">			 fontWeight.dragging=<span style="color: #ff0000;">&quot;bold&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:ItemRenderer</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>When the Spark List creates the duplicate ItemRenderes for the drag indicator, it will set them to their &#8220;dragging&#8221; state. Note that at that point the List&#8217;s data item will be rendered by two ItemRender instances &#8211; one to display the item in the List itself and one to display the item in the drag indicator.</p>
<h2>Customize the Drop Indicator</h2>
<p>I&#8217;ll set up a custom List skin. I&#8217;ll replace the &#8220;dropIndicator&#8221; skin part. Note that since the part is a dynamic part (created only during drag-and-drop operation) it&#8217;s placed inside the &lt;fx:Declarations/&gt; tag.<br />
CustomDropIndicatorListSkin.mxml:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"> <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!--- </span>
<span style="color: #000000;">          Defines the appearance of the the List's drop indicator.</span>
<span style="color: #000000;">          To customize the drop indicator appearance, create a custom ListSkin class.</span>
<span style="color: #000000;">          The List's layout takes care to size and position the dropIndicator.</span>
<span style="color: #000000;">          The size of the &lt;code&gt;</span></span>dropIndicator<span style="color: #000000;">&lt;/code<span style="color: #7400FF;">&gt;</span></span> is typically set to the size of the 
          gaps between the items.
          The minimum and maximum settings are typically respected only in the direction
          along the major axis (the gap axis).  For example a VerticalLayout ignores the 
          <span style="color: #000000;">&lt;code<span style="color: #7400FF;">&gt;</span></span>minWidth<span style="color: #000000;">&lt;/code<span style="color: #7400FF;">&gt;</span></span> and <span style="color: #000000;">&lt;code<span style="color: #7400FF;">&gt;</span></span>maxWidth<span style="color: #000000;">&lt;/code<span style="color: #7400FF;">&gt;</span></span> settings, 
          but respect <span style="color: #000000;">&lt;code<span style="color: #7400FF;">&gt;</span></span>minHeight<span style="color: #000000;">&lt;/code<span style="color: #7400FF;">&gt;</span></span> and <span style="color: #000000;">&lt;code<span style="color: #7400FF;">&gt;</span></span>maxHeight<span style="color: #000000;">&lt;/code<span style="color: #7400FF;">&gt;</span></span>. 
&nbsp;
          @copy spark.components.List#dropIndicator
    --&gt;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Component</span> id=<span style="color: #ff0000;">&quot;dropIndicator&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Group</span> minWidth=<span style="color: #ff0000;">&quot;3&quot;</span> minHeight=<span style="color: #ff0000;">&quot;3&quot;</span> maxWidth=<span style="color: #ff0000;">&quot;3&quot;</span> maxHeight=<span style="color: #ff0000;">&quot;3&quot;</span><span style="color: #7400FF;">&gt;</span></span>
			<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Line</span> width=<span style="color: #ff0000;">&quot;20&quot;</span> left=<span style="color: #ff0000;">&quot;3&quot;</span> verticalCenter=<span style="color: #ff0000;">&quot;2&quot;</span><span style="color: #7400FF;">&gt;</span></span>
				<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:stroke</span><span style="color: #7400FF;">&gt;</span></span>
					<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:SolidColorStroke</span> color=<span style="color: #ff0000;">&quot;0xFF0000&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
				<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:stroke</span><span style="color: #7400FF;">&gt;</span></span>
			<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Line</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
			<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Path</span> left=<span style="color: #ff0000;">&quot;50&quot;</span> verticalCenter=<span style="color: #ff0000;">&quot;-2&quot;</span> scaleX=<span style="color: #ff0000;">&quot;-1&quot;</span> </span>
<span style="color: #000000;">					data=<span style="color: #ff0000;">&quot;M 0 5 L 30 5 26 0 40 8 26 16 30 11 0 11 Z&quot;</span><span style="color: #7400FF;">&gt;</span></span>
				<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:stroke</span><span style="color: #7400FF;">&gt;</span></span>
					<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:LinearGradientStroke</span> rotation=<span style="color: #ff0000;">&quot;5&quot;</span> weight=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #7400FF;">&gt;</span></span>
						<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:GradientEntry</span> color=<span style="color: #ff0000;">&quot;0xD8D8D8&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
						<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:GradientEntry</span> color=<span style="color: #ff0000;">&quot;0x000000&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
					<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:LinearGradientStroke</span><span style="color: #7400FF;">&gt;</span></span>
				<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:stroke</span><span style="color: #7400FF;">&gt;</span></span>
				<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:fill</span><span style="color: #7400FF;">&gt;</span></span>
					<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:LinearGradient</span> rotation=<span style="color: #ff0000;">&quot;90&quot;</span><span style="color: #7400FF;">&gt;</span></span>
						<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:GradientEntry</span> color=<span style="color: #ff0000;">&quot;0xD8D8D8&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
						<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:GradientEntry</span> color=<span style="color: #ff0000;">&quot;0x888888&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
					<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:LinearGradient</span><span style="color: #7400FF;">&gt;</span></span>
				<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:fill</span><span style="color: #7400FF;">&gt;</span></span>
			<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Path</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Group</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Component</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>Click on the image at the top of the page to see the example in action. The sources are available <a href='http://evtimmy.com/wordpress/wp-content/uploads/2010/01/dndlistskinning.zip'>here</a>. The example was compiled with the Gumbo Flex SDK build 13553.</p>
]]></content:encoded>
			<wfw:commentRss>http://evtimmy.com/2010/01/drag-and-drop-skinning-in-spark/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Calculating the Projected Bounds using Utils3D.projectVector()</title>
		<link>http://evtimmy.com/2009/12/calculating-the-projected-bounds-using-utils3dprojectvector/</link>
		<comments>http://evtimmy.com/2009/12/calculating-the-projected-bounds-using-utils3dprojectvector/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 07:23:47 +0000</pubDate>
		<dc:creator>Evtim</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[bounds]]></category>
		<category><![CDATA[perspectiveProjection]]></category>
		<category><![CDATA[Utils3D]]></category>

		<guid isPermaLink="false">http://evtimmy.com/?p=173</guid>
		<description><![CDATA[If you are playing with objects in 3D and want their projected bounds, there&#8217;s a neat flash functionality for that &#8211; Utils3D.projectVector(). However it may not be that apparent how to use it. Here I&#8217;m showing a small helper function that does the trick. The projectVector() method actually takes a Matrix3D for a parameter. Note [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://evtimmy.com/wordpress/wp-content/uploads/2009/12/projectedbounds.swf"><img class="size-full wp-image-178 alignleft" title="projectedbounds" src="http://evtimmy.com/wordpress/wp-content/uploads/2009/12/projectedbounds.png" alt="projectedbounds" width="142" height="124" /></a>If you are playing with objects in 3D and want their projected bounds, there&#8217;s a neat flash functionality for that &#8211; Utils3D.projectVector(). However it may not be that apparent how to use it. Here I&#8217;m showing a small helper function that does the trick.<br />
<span id="more-173"></span>The projectVector() method actually takes a Matrix3D for a parameter. Note that here you should pass in the Matrix3D of the object in question combined with the perspective projection of its parent. This is not as trivial as it seems, as you&#8217;d need to also translate by the projectionCenter and the focalLength:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>16
17
18
19
20
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900; font-style: italic;">// Setup the matrix</span>
 <span style="color: #6699cc; font-weight: bold;">var</span> centerX<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = projection<span style="color: #000066; font-weight: bold;">.</span>projectionCenter<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">;</span>
 <span style="color: #6699cc; font-weight: bold;">var</span> centerY<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = projection<span style="color: #000066; font-weight: bold;">.</span>projectionCenter<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">;</span>
 <span style="color: #004993;">matrix</span><span style="color: #000066; font-weight: bold;">.</span>appendTranslation<span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">-</span>centerX<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000066; font-weight: bold;">-</span>centerY<span style="color: #000066; font-weight: bold;">,</span> projection<span style="color: #000066; font-weight: bold;">.</span>focalLength<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
 <span style="color: #004993;">matrix</span><span style="color: #000066; font-weight: bold;">.</span>append<span style="color: #000000;">&#40;</span>projection<span style="color: #000066; font-weight: bold;">.</span>toMatrix3D<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></td></tr></table></div>

<p>After that just pass in the matrix and the point to be projected to Utils3D.projectVector(). Then translate the result by centerX and centerY.<br />
Here&#8217;s the helper function source, it takes in bounds, the matrix of the object and the perspective projection and returns the projected 2D bounds:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> projectBounds<span style="color: #000000;">&#40;</span>bounds<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Rectangle</span><span style="color: #000066; font-weight: bold;">,</span>
 <span style="color: #004993;">matrix</span><span style="color: #000066; font-weight: bold;">:</span>Matrix3D<span style="color: #000066; font-weight: bold;">,</span>
 projection<span style="color: #000066; font-weight: bold;">:</span>PerspectiveProjection<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Rectangle</span>
 <span style="color: #000000;">&#123;</span>
 <span style="color: #009900; font-style: italic;">// Setup the matrix</span>
 <span style="color: #6699cc; font-weight: bold;">var</span> centerX<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = projection<span style="color: #000066; font-weight: bold;">.</span>projectionCenter<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">;</span>
 <span style="color: #6699cc; font-weight: bold;">var</span> centerY<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = projection<span style="color: #000066; font-weight: bold;">.</span>projectionCenter<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">;</span>
 <span style="color: #004993;">matrix</span><span style="color: #000066; font-weight: bold;">.</span>appendTranslation<span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">-</span>centerX<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000066; font-weight: bold;">-</span>centerY<span style="color: #000066; font-weight: bold;">,</span> projection<span style="color: #000066; font-weight: bold;">.</span>focalLength<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
 <span style="color: #004993;">matrix</span><span style="color: #000066; font-weight: bold;">.</span>append<span style="color: #000000;">&#40;</span>projection<span style="color: #000066; font-weight: bold;">.</span>toMatrix3D<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">// Project the corner points</span>
 <span style="color: #6699cc; font-weight: bold;">var</span> pt1<span style="color: #000066; font-weight: bold;">:</span>Vector3D = <span style="color: #0033ff; font-weight: bold;">new</span> Vector3D<span style="color: #000000;">&#40;</span>bounds<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">left</span><span style="color: #000066; font-weight: bold;">,</span> bounds<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">top</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
 <span style="color: #6699cc; font-weight: bold;">var</span> pt2<span style="color: #000066; font-weight: bold;">:</span>Vector3D = <span style="color: #0033ff; font-weight: bold;">new</span> Vector3D<span style="color: #000000;">&#40;</span>bounds<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">right</span><span style="color: #000066; font-weight: bold;">,</span> bounds<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">top</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span>
 <span style="color: #6699cc; font-weight: bold;">var</span> pt3<span style="color: #000066; font-weight: bold;">:</span>Vector3D = <span style="color: #0033ff; font-weight: bold;">new</span> Vector3D<span style="color: #000000;">&#40;</span>bounds<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">left</span><span style="color: #000066; font-weight: bold;">,</span> bounds<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">bottom</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
 <span style="color: #6699cc; font-weight: bold;">var</span> pt4<span style="color: #000066; font-weight: bold;">:</span>Vector3D = <span style="color: #0033ff; font-weight: bold;">new</span> Vector3D<span style="color: #000000;">&#40;</span>bounds<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">right</span><span style="color: #000066; font-weight: bold;">,</span> bounds<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">bottom</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
 pt1 = Utils3D<span style="color: #000066; font-weight: bold;">.</span>projectVector<span style="color: #000000;">&#40;</span><span style="color: #004993;">matrix</span><span style="color: #000066; font-weight: bold;">,</span> pt1<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
 pt2 = Utils3D<span style="color: #000066; font-weight: bold;">.</span>projectVector<span style="color: #000000;">&#40;</span><span style="color: #004993;">matrix</span><span style="color: #000066; font-weight: bold;">,</span> pt2<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
 pt3 = Utils3D<span style="color: #000066; font-weight: bold;">.</span>projectVector<span style="color: #000000;">&#40;</span><span style="color: #004993;">matrix</span><span style="color: #000066; font-weight: bold;">,</span> pt3<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
 pt4 = Utils3D<span style="color: #000066; font-weight: bold;">.</span>projectVector<span style="color: #000000;">&#40;</span><span style="color: #004993;">matrix</span><span style="color: #000066; font-weight: bold;">,</span> pt4<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">// Find the bounding box in 2D</span>
 <span style="color: #6699cc; font-weight: bold;">var</span> maxX<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">max</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">max</span><span style="color: #000000;">&#40;</span>pt1<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span> pt2<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">max</span><span style="color: #000000;">&#40;</span>pt3<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span> pt4<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
 <span style="color: #6699cc; font-weight: bold;">var</span> minX<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">min</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">min</span><span style="color: #000000;">&#40;</span>pt1<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span> pt2<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">min</span><span style="color: #000000;">&#40;</span>pt3<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span> pt4<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
 <span style="color: #6699cc; font-weight: bold;">var</span> maxY<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">max</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">max</span><span style="color: #000000;">&#40;</span>pt1<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">,</span> pt2<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">max</span><span style="color: #000000;">&#40;</span>pt3<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">,</span> pt4<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
 <span style="color: #6699cc; font-weight: bold;">var</span> minY<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">min</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">min</span><span style="color: #000000;">&#40;</span>pt1<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">,</span> pt2<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">min</span><span style="color: #000000;">&#40;</span>pt3<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">,</span> pt4<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">// Add back the projection center</span>
 bounds<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = minX <span style="color: #000066; font-weight: bold;">+</span> centerX<span style="color: #000066; font-weight: bold;">;</span>
 bounds<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = minY <span style="color: #000066; font-weight: bold;">+</span> centerY<span style="color: #000066; font-weight: bold;">;</span>
 bounds<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> = maxX <span style="color: #000066; font-weight: bold;">-</span> minX<span style="color: #000066; font-weight: bold;">;</span>
 bounds<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> = maxY <span style="color: #000066; font-weight: bold;">-</span> minY<span style="color: #000066; font-weight: bold;">;</span>
 <span style="color: #0033ff; font-weight: bold;">return</span> bounds<span style="color: #000066; font-weight: bold;">;</span>
 <span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>The full source is here <a href='http://evtimmy.com/wordpress/wp-content/uploads/2009/12/projectedbounds.mxml'>projectedbounds.mxml</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://evtimmy.com/2009/12/calculating-the-projected-bounds-using-utils3dprojectvector/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Spark Layouts with Flex 4 Beta</title>
		<link>http://evtimmy.com/2009/10/spark-layouts-with-flex-4-beta/</link>
		<comments>http://evtimmy.com/2009/10/spark-layouts-with-flex-4-beta/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 19:14:10 +0000</pubDate>
		<dc:creator>Evtim</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://evtimmy.com/?p=153</guid>
		<description><![CDATA[Just a quick post to link to my layouts  article on the Adobe dev connection. It uses the same FlowLayout as an example, so no surprises in that department. Check it out, comments and feedback greatly appreciated.]]></description>
			<content:encoded><![CDATA[<p>Just a quick post to link to my layouts  <a href="http://www.adobe.com/devnet/flex/articles/spark_layouts.html">article</a> on the Adobe dev connection. It uses the same FlowLayout as an example, so no surprises in that department. Check it out, comments and feedback greatly appreciated.</p>
]]></content:encoded>
			<wfw:commentRss>http://evtimmy.com/2009/10/spark-layouts-with-flex-4-beta/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
	</channel>
</rss>

