<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Spark Layouts with Flex 4 Beta</title>
	<atom:link href="http://evtimmy.com/2009/10/spark-layouts-with-flex-4-beta/feed/" rel="self" type="application/rss+xml" />
	<link>http://evtimmy.com/2009/10/spark-layouts-with-flex-4-beta/</link>
	<description>Evtim on Flex SDK</description>
	<lastBuildDate>Thu, 03 May 2012 14:48:24 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Evtim</title>
		<link>http://evtimmy.com/2009/10/spark-layouts-with-flex-4-beta/comment-page-1/#comment-11529</link>
		<dc:creator>Evtim</dc:creator>
		<pubDate>Mon, 12 Apr 2010 06:59:21 +0000</pubDate>
		<guid isPermaLink="false">http://evtimmy.com/?p=153#comment-11529</guid>
		<description>Hi Jason,
Yup, when the dataProvider is null or empty the layout still runs, but it should be easy to do an early return in that case.
Not quite sure what&#039;s going on there... are you adding the items within your updateDisplayList or outside of the layout? 
Regarding my previous suggestion - about having a separate array to sort so that you don&#039;t modify the dataProvider within your layout - this is not going to double your data since every Array element is going to be simply pointing to an item in the dataProvider. Essentially you&#039;ll temporarily create an Array of references to the original items, sort that Array and work on it, then throw it away.</description>
		<content:encoded><![CDATA[<p>Hi Jason,<br />
Yup, when the dataProvider is null or empty the layout still runs, but it should be easy to do an early return in that case.<br />
Not quite sure what&#8217;s going on there&#8230; are you adding the items within your updateDisplayList or outside of the layout?<br />
Regarding my previous suggestion &#8211; about having a separate array to sort so that you don&#8217;t modify the dataProvider within your layout &#8211; this is not going to double your data since every Array element is going to be simply pointing to an item in the dataProvider. Essentially you&#8217;ll temporarily create an Array of references to the original items, sort that Array and work on it, then throw it away.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason</title>
		<link>http://evtimmy.com/2009/10/spark-layouts-with-flex-4-beta/comment-page-1/#comment-11525</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Tue, 06 Apr 2010 05:07:11 +0000</pubDate>
		<guid isPermaLink="false">http://evtimmy.com/?p=153#comment-11525</guid>
		<description>Evtim, I was wondering if you could help me understand a couple of behaviors that are tripping me up a bit.
1. updateDisplayList is called for a DataGroup even when the dataProvider is empty when the application first launches.

2. Normally, this isn&#039;t such a big deal, however, depending on how you add data to the dataProvider, it can throw an error.

For example, the following works, however, it triggers an updateDisplayList for each item:
acOne.addAll(acOneTemp);

So, to be a bit more efficient, I wanted to pass the entire array to the DataGroups dataProvider, so it could loop through the dataProvider 1 time to perform the layout. So I tried this:

acOne.source = acOneTemp.source;

For some reason, this causes a run-time error and it doesn&#039;t like this line:

element.setLayoutBoundsSize(NaN, NaN);

TypeError: Error #1009: Cannot access a property or method of a null object reference.</description>
		<content:encoded><![CDATA[<p>Evtim, I was wondering if you could help me understand a couple of behaviors that are tripping me up a bit.<br />
1. updateDisplayList is called for a DataGroup even when the dataProvider is empty when the application first launches.</p>
<p>2. Normally, this isn&#8217;t such a big deal, however, depending on how you add data to the dataProvider, it can throw an error.</p>
<p>For example, the following works, however, it triggers an updateDisplayList for each item:<br />
acOne.addAll(acOneTemp);</p>
<p>So, to be a bit more efficient, I wanted to pass the entire array to the DataGroups dataProvider, so it could loop through the dataProvider 1 time to perform the layout. So I tried this:</p>
<p>acOne.source = acOneTemp.source;</p>
<p>For some reason, this causes a run-time error and it doesn&#8217;t like this line:</p>
<p>element.setLayoutBoundsSize(NaN, NaN);</p>
<p>TypeError: Error #1009: Cannot access a property or method of a null object reference.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason</title>
		<link>http://evtimmy.com/2009/10/spark-layouts-with-flex-4-beta/comment-page-1/#comment-11521</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Wed, 24 Mar 2010 07:23:55 +0000</pubDate>
		<guid isPermaLink="false">http://evtimmy.com/?p=153#comment-11521</guid>
		<description>&lt;a href=&quot;#comment-11520&quot; rel=&quot;nofollow&quot;&gt;@Evtim  &lt;/a&gt; 
I&#039;m not sure I want to carry the data twice in my app, as it can be a lot of data, so I tried something along those lines. What I did was add an item to the array (e.g. RowNum) and looped through the data provider, when the DataGroup is initialized, to set the original order of the array. Then, I sort the array back to the original order before the updateDisplayList or as the first step in updateDisplayList.

Something to consider for future releases is a tighter integration between rendered element and the items in the data provider, so if the data provider gets sorted, it doesn&#039;t throw off the display. Sorting is pretty common, so I imagine others will struggle with this as well.</description>
		<content:encoded><![CDATA[<p><a href="#comment-11520" rel="nofollow">@Evtim  </a><br />
I&#8217;m not sure I want to carry the data twice in my app, as it can be a lot of data, so I tried something along those lines. What I did was add an item to the array (e.g. RowNum) and looped through the data provider, when the DataGroup is initialized, to set the original order of the array. Then, I sort the array back to the original order before the updateDisplayList or as the first step in updateDisplayList.</p>
<p>Something to consider for future releases is a tighter integration between rendered element and the items in the data provider, so if the data provider gets sorted, it doesn&#8217;t throw off the display. Sorting is pretty common, so I imagine others will struggle with this as well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Evtim</title>
		<link>http://evtimmy.com/2009/10/spark-layouts-with-flex-4-beta/comment-page-1/#comment-11520</link>
		<dc:creator>Evtim</dc:creator>
		<pubDate>Wed, 24 Mar 2010 06:18:42 +0000</pubDate>
		<guid isPermaLink="false">http://evtimmy.com/?p=153#comment-11520</guid>
		<description>Hi Jason,
How about creating a separate Array with references to the items from the dataProvider and sorting that internal array and operating on it? This way you still have the items sorted, but you don&#039;t modify the dataProvider. If you have to modify the dataProvider, then I think your best bet is to find a way to do it outside of the layout&#039;s updateDisplayList().
-Evtim</description>
		<content:encoded><![CDATA[<p>Hi Jason,<br />
How about creating a separate Array with references to the items from the dataProvider and sorting that internal array and operating on it? This way you still have the items sorted, but you don&#8217;t modify the dataProvider. If you have to modify the dataProvider, then I think your best bet is to find a way to do it outside of the layout&#8217;s updateDisplayList().<br />
-Evtim</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason</title>
		<link>http://evtimmy.com/2009/10/spark-layouts-with-flex-4-beta/comment-page-1/#comment-11519</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Tue, 23 Mar 2010 20:14:14 +0000</pubDate>
		<guid isPermaLink="false">http://evtimmy.com/?p=153#comment-11519</guid>
		<description>&lt;a href=&quot;#comment-11518&quot; rel=&quot;nofollow&quot;&gt;@Jason  &lt;/a&gt; 

Slight correcting...I comment out the following line and the display updates correctly, however, I need the sort to assist in calculating width and x.

dataProvider.source.sortOn([&quot;Height&quot;], [Array.NUMERIC &#124; Array.DESCENDING]);</description>
		<content:encoded><![CDATA[<p><a href="#comment-11518" rel="nofollow">@Jason  </a> </p>
<p>Slight correcting&#8230;I comment out the following line and the display updates correctly, however, I need the sort to assist in calculating width and x.</p>
<p>dataProvider.source.sortOn(["Height"], [Array.NUMERIC | Array.DESCENDING]);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason</title>
		<link>http://evtimmy.com/2009/10/spark-layouts-with-flex-4-beta/comment-page-1/#comment-11518</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Tue, 23 Mar 2010 20:11:25 +0000</pubDate>
		<guid isPermaLink="false">http://evtimmy.com/?p=153#comment-11518</guid>
		<description>&lt;a href=&quot;#comment-11512&quot; rel=&quot;nofollow&quot;&gt;@Evtim  &lt;/a&gt; 
Evtim,

I&#039;ve made significant progress with some of your pointers!! However, I&#039;m still stuck on one area, and that is the sorting the dataProvider is throwing things off, if I change the underlying data in the dataProvider after the initial updateDisplayList.

I have an example FXP project that demonstrates the issue, but I don&#039;t have a place to post it since I can&#039;t upload to the Adobe Forums, so I&#039;ll try and copy the relevant pieces below. If I comment out this line:

dataProvider = ArrayCollection(DataGroup(target).dataProvider);

The display elements update when I reSize an item, however, I need to use the sorting. The sorting is not relevant to this example application, but I need to use it.

customLayout.as

package myLayout 
{
	import mx.collections.ArrayCollection;
	import mx.core.ILayoutElement;
	
	import spark.components.DataGroup;
	import spark.components.supportClasses.GroupBase;
	import spark.components.supportClasses.ItemRenderer;
	import spark.layouts.supportClasses.LayoutBase;
	
	public class customLayout extends LayoutBase {
		public var layoutTarget:GroupBase;
		public var count:int;
		public var dataProvider:ArrayCollection;
		public var maxHeight:Number = 0;
		public var maxWidth:Number;
		public var x:Number;
		public var y:Number;
		
		public function setLayout():void {
			layoutTarget = this.target;
			dataProvider = ArrayCollection(DataGroup(target).dataProvider);
			count = layoutTarget.numElements;
			dataProvider.source.sortOn([&quot;Height&quot;], [Array.NUMERIC &#124; Array.DESCENDING]);
			if (dataProvider[0].Height &gt; dataProvider[1].Height) {
				dataProvider[0].xPos = 0;
				dataProvider[1].xPos = 60;
			}
			else if (dataProvider[1].Height &gt; dataProvider[0].Height) {
				dataProvider[1].xPos = 0;
				dataProvider[0].xPos = 60;
			}
		}
		
		override public function updateDisplayList(containerWidth:Number, containerHeight:Number):void {			
			for (var ii:int = 0; ii &lt; count; ii++) {
				// get the current element, we&#039;re going to work with the
				// ILayoutElement interface
				
				var element:ILayoutElement = layoutTarget.getElementAt(ii);
				var item:ItemRenderer = target.getElementAt(ii) as ItemRenderer;
			
				// Resize the element to its preferred size by passing
				// NaN for the width and height constraints
				element.setLayoutBoundsSize(NaN, NaN);
				
				// Find out the element&#039;s dimensions sizes.
				// We do this after the element has been already resized
				// to its preferred size.
				var elementWidth:Number = element.getLayoutBoundsWidth();
				var elementHeight:Number = element.getLayoutBoundsHeight();
				item.uid = String(ii);
				
				y = 0;
				x = dataProvider[ii].xPos;				
				// Find maximum element extents. This is needed for
				// the scrolling support.
				maxWidth = 50;
				maxHeight = dataProvider[ii].Height;
				
				// Position the element
				element.setLayoutBoundsPosition(x, y);
				element.setLayoutBoundsSize(maxWidth, maxHeight);				
			}
			// Scrolling support - update the content size
			layoutTarget.setContentSize(maxWidth, maxHeight);
		}
	}
}


DataGroup.mxml



	
		&lt;!-- Place non-visual elements (e.g., services, value objects) here --&gt;
	
	
	
		 49) {
					myAC[itemID].Height = myAC[itemID].Height + event.stageY - initY;
					resizingElement.height = resizingElement.height + event.stageY - initY;
					initY = event.stageY;
				}
			}
			
			protected function mouseUpHandler(event:MouseEvent):void {
				cLayout.setLayout();
				this.invalidateDisplayList();
				systemManager.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler, true);
				systemManager.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler, true);				
			}

		]]&gt;
	
	
	
		
	
	



Jason</description>
		<content:encoded><![CDATA[<p><a href="#comment-11512" rel="nofollow">@Evtim  </a><br />
Evtim,</p>
<p>I&#8217;ve made significant progress with some of your pointers!! However, I&#8217;m still stuck on one area, and that is the sorting the dataProvider is throwing things off, if I change the underlying data in the dataProvider after the initial updateDisplayList.</p>
<p>I have an example FXP project that demonstrates the issue, but I don&#8217;t have a place to post it since I can&#8217;t upload to the Adobe Forums, so I&#8217;ll try and copy the relevant pieces below. If I comment out this line:</p>
<p>dataProvider = ArrayCollection(DataGroup(target).dataProvider);</p>
<p>The display elements update when I reSize an item, however, I need to use the sorting. The sorting is not relevant to this example application, but I need to use it.</p>
<p>customLayout.as</p>
<p>package myLayout<br />
{<br />
	import mx.collections.ArrayCollection;<br />
	import mx.core.ILayoutElement;</p>
<p>	import spark.components.DataGroup;<br />
	import spark.components.supportClasses.GroupBase;<br />
	import spark.components.supportClasses.ItemRenderer;<br />
	import spark.layouts.supportClasses.LayoutBase;</p>
<p>	public class customLayout extends LayoutBase {<br />
		public var layoutTarget:GroupBase;<br />
		public var count:int;<br />
		public var dataProvider:ArrayCollection;<br />
		public var maxHeight:Number = 0;<br />
		public var maxWidth:Number;<br />
		public var x:Number;<br />
		public var y:Number;</p>
<p>		public function setLayout():void {<br />
			layoutTarget = this.target;<br />
			dataProvider = ArrayCollection(DataGroup(target).dataProvider);<br />
			count = layoutTarget.numElements;<br />
			dataProvider.source.sortOn(["Height"], [Array.NUMERIC | Array.DESCENDING]);<br />
			if (dataProvider[0].Height &gt; dataProvider[1].Height) {<br />
				dataProvider[0].xPos = 0;<br />
				dataProvider[1].xPos = 60;<br />
			}<br />
			else if (dataProvider[1].Height &gt; dataProvider[0].Height) {<br />
				dataProvider[1].xPos = 0;<br />
				dataProvider[0].xPos = 60;<br />
			}<br />
		}</p>
<p>		override public function updateDisplayList(containerWidth:Number, containerHeight:Number):void {<br />
			for (var ii:int = 0; ii &lt; count; ii++) {<br />
				// get the current element, we&#8217;re going to work with the<br />
				// ILayoutElement interface</p>
<p>				var element:ILayoutElement = layoutTarget.getElementAt(ii);<br />
				var item:ItemRenderer = target.getElementAt(ii) as ItemRenderer;</p>
<p>				// Resize the element to its preferred size by passing<br />
				// NaN for the width and height constraints<br />
				element.setLayoutBoundsSize(NaN, NaN);</p>
<p>				// Find out the element&#8217;s dimensions sizes.<br />
				// We do this after the element has been already resized<br />
				// to its preferred size.<br />
				var elementWidth:Number = element.getLayoutBoundsWidth();<br />
				var elementHeight:Number = element.getLayoutBoundsHeight();<br />
				item.uid = String(ii);</p>
<p>				y = 0;<br />
				x = dataProvider[ii].xPos;<br />
				// Find maximum element extents. This is needed for<br />
				// the scrolling support.<br />
				maxWidth = 50;<br />
				maxHeight = dataProvider[ii].Height;</p>
<p>				// Position the element<br />
				element.setLayoutBoundsPosition(x, y);<br />
				element.setLayoutBoundsSize(maxWidth, maxHeight);<br />
			}<br />
			// Scrolling support &#8211; update the content size<br />
			layoutTarget.setContentSize(maxWidth, maxHeight);<br />
		}<br />
	}<br />
}</p>
<p>DataGroup.mxml</p>
<p>		<!-- Place non-visual elements (e.g., services, value objects) here --></p>
<p>		 49) {<br />
					myAC[itemID].Height = myAC[itemID].Height + event.stageY &#8211; initY;<br />
					resizingElement.height = resizingElement.height + event.stageY &#8211; initY;<br />
					initY = event.stageY;<br />
				}<br />
			}</p>
<p>			protected function mouseUpHandler(event:MouseEvent):void {<br />
				cLayout.setLayout();<br />
				this.invalidateDisplayList();<br />
				systemManager.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler, true);<br />
				systemManager.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler, true);<br />
			}</p>
<p>		]]&gt;</p>
<p>Jason</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason</title>
		<link>http://evtimmy.com/2009/10/spark-layouts-with-flex-4-beta/comment-page-1/#comment-11515</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Wed, 17 Mar 2010 06:15:08 +0000</pubDate>
		<guid isPermaLink="false">http://evtimmy.com/?p=153#comment-11515</guid>
		<description>&lt;a href=&quot;#comment-11512&quot; rel=&quot;nofollow&quot;&gt;@Evtim  &lt;/a&gt;
Hopefully, this sample code will give you a better idea of what I&#039;m trying to do. If I take the initial functions outside of updateDisplayList(), I can&#039;t seem to access the target or the dataProvider, I get null errors. Example code is as follows:

package MyLayout 
{
	import mx.collections.ArrayCollection;
	import mx.core.ILayoutElement;
	
	import spark.components.DataGroup;
	import spark.components.supportClasses.GroupBase;
	import spark.components.supportClasses.ItemRenderer;
	import spark.layouts.supportClasses.LayoutBase;
	
	public class calLayout extends LayoutBase {
		override public function updateDisplayList(containerWidth:Number, containerHeight:Number):void {
			var x:Number = 0;
			var y:Number = 0;
			var layoutTarget:GroupBase = target;
			var count:int = layoutTarget.numElements;
			var dataProvider:ArrayCollection = ArrayCollection(DataGroup(target).dataProvider);
			layoutOne();
			
			function layoutOne():void {
				dataProvider.source.sortOn([&quot;y&quot;, &quot;Height&quot;], [Array.NUMERIC, Array.NUMERIC &#124; Array.DESCENDING]);
				for (var i:int = 1; i &lt; dataProvider.length; i++) {
					//Sets group and maxGroup
				}
				layoutTwo();
			}
			
			function layoutTwo():void {
				dataProvider.source.sortOn([&quot;Group&quot;, &quot;y&quot;, &quot;Height&quot;], [Array.NUMERIC, Array.NUMERIC, Array.NUMERIC &#124; Array.DESCENDING]);
				for (var ii:int = 1; ii &lt; maxGroup+1; ii++) {
					//Does something else, but is dependant on values calculated in previous 
					//function, and must be calculated for all items in Array before proceeding.
				}
				layoutThree();
			}
			
			function setColumnPosition1(): void {
				dataProvider.source.sortOn([&quot;Group&quot;, &quot;y&quot;, &quot;Height&quot;], [Array.NUMERIC, Array.NUMERIC, Array.NUMERIC &#124; Array.DESCENDING]);
				for (var vi:int=0; vi &lt; dataProvider.length; vi++) {
					//Does something else, but is dependant on values calculated in previous 
					//function, and must be calculated for all items in Array before proceeding.
				}
			}
			
			
			for (var viv:int = 0; viv &lt; count; viv++) {
				// get the current element, we&#039;re going to work with the
				// ILayoutElement interface
				
				var element:ILayoutElement = layoutTarget.getElementAt(viv);
				var item:ItemRenderer = target.getElementAt(viv) as ItemRenderer;
				

				// Resize the element to its preferred size by passing
				// NaN for the width and height constraints
				element.setLayoutBoundsSize(NaN, NaN);

				// Find out the element&#039;s dimensions sizes.
				// We do this after the element has been already resized
				// to its preferred size.
				var elementWidth:Number = element.getLayoutBoundsWidth();
				var elementHeight:Number = element.getLayoutBoundsHeight();
				var dataID:Number;
				for (var vv:int = 0; vv &lt; dataProvider.length; vv++) {
					if (dataProvider[vv].apID == item.data.apID) {
						y = dataProvider[vv].y;
						x = SOME FORMULA
						// Find maximum element extents. This is needed for
						// the scrolling support.
						maxWidth = dataProvider[vv].Width;
						maxHeight = target.height;
						break;
					}
				}				
								
				// Position the element
				element.setLayoutBoundsPosition(x, y);
				element.setLayoutBoundsSize(dataProvider[vv].Width, dataProvider[vv].Height);
			}
			
			// Scrolling support - update the content size
			layoutTarget.setContentSize(maxWidth, maxHeight);
		}
	}
}</description>
		<content:encoded><![CDATA[<p><a href="#comment-11512" rel="nofollow">@Evtim  </a><br />
Hopefully, this sample code will give you a better idea of what I&#8217;m trying to do. If I take the initial functions outside of updateDisplayList(), I can&#8217;t seem to access the target or the dataProvider, I get null errors. Example code is as follows:</p>
<p>package MyLayout<br />
{<br />
	import mx.collections.ArrayCollection;<br />
	import mx.core.ILayoutElement;</p>
<p>	import spark.components.DataGroup;<br />
	import spark.components.supportClasses.GroupBase;<br />
	import spark.components.supportClasses.ItemRenderer;<br />
	import spark.layouts.supportClasses.LayoutBase;</p>
<p>	public class calLayout extends LayoutBase {<br />
		override public function updateDisplayList(containerWidth:Number, containerHeight:Number):void {<br />
			var x:Number = 0;<br />
			var y:Number = 0;<br />
			var layoutTarget:GroupBase = target;<br />
			var count:int = layoutTarget.numElements;<br />
			var dataProvider:ArrayCollection = ArrayCollection(DataGroup(target).dataProvider);<br />
			layoutOne();</p>
<p>			function layoutOne():void {<br />
				dataProvider.source.sortOn(["y", "Height"], [Array.NUMERIC, Array.NUMERIC | Array.DESCENDING]);<br />
				for (var i:int = 1; i &lt; dataProvider.length; i++) {<br />
					//Sets group and maxGroup<br />
				}<br />
				layoutTwo();<br />
			}</p>
<p>			function layoutTwo():void {<br />
				dataProvider.source.sortOn(["Group", "y", "Height"], [Array.NUMERIC, Array.NUMERIC, Array.NUMERIC | Array.DESCENDING]);<br />
				for (var ii:int = 1; ii &lt; maxGroup+1; ii++) {<br />
					//Does something else, but is dependant on values calculated in previous<br />
					//function, and must be calculated for all items in Array before proceeding.<br />
				}<br />
				layoutThree();<br />
			}</p>
<p>			function setColumnPosition1(): void {<br />
				dataProvider.source.sortOn(["Group", "y", "Height"], [Array.NUMERIC, Array.NUMERIC, Array.NUMERIC | Array.DESCENDING]);<br />
				for (var vi:int=0; vi &lt; dataProvider.length; vi++) {<br />
					//Does something else, but is dependant on values calculated in previous<br />
					//function, and must be calculated for all items in Array before proceeding.<br />
				}<br />
			}</p>
<p>			for (var viv:int = 0; viv &lt; count; viv++) {<br />
				// get the current element, we&#8217;re going to work with the<br />
				// ILayoutElement interface</p>
<p>				var element:ILayoutElement = layoutTarget.getElementAt(viv);<br />
				var item:ItemRenderer = target.getElementAt(viv) as ItemRenderer;</p>
<p>				// Resize the element to its preferred size by passing<br />
				// NaN for the width and height constraints<br />
				element.setLayoutBoundsSize(NaN, NaN);</p>
<p>				// Find out the element&#8217;s dimensions sizes.<br />
				// We do this after the element has been already resized<br />
				// to its preferred size.<br />
				var elementWidth:Number = element.getLayoutBoundsWidth();<br />
				var elementHeight:Number = element.getLayoutBoundsHeight();<br />
				var dataID:Number;<br />
				for (var vv:int = 0; vv &lt; dataProvider.length; vv++) {<br />
					if (dataProvider[vv].apID == item.data.apID) {<br />
						y = dataProvider[vv].y;<br />
						x = SOME FORMULA<br />
						// Find maximum element extents. This is needed for<br />
						// the scrolling support.<br />
						maxWidth = dataProvider[vv].Width;<br />
						maxHeight = target.height;<br />
						break;<br />
					}<br />
				}				</p>
<p>				// Position the element<br />
				element.setLayoutBoundsPosition(x, y);<br />
				element.setLayoutBoundsSize(dataProvider[vv].Width, dataProvider[vv].Height);<br />
			}</p>
<p>			// Scrolling support &#8211; update the content size<br />
			layoutTarget.setContentSize(maxWidth, maxHeight);<br />
		}<br />
	}<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason</title>
		<link>http://evtimmy.com/2009/10/spark-layouts-with-flex-4-beta/comment-page-1/#comment-11514</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Wed, 17 Mar 2010 05:14:31 +0000</pubDate>
		<guid isPermaLink="false">http://evtimmy.com/?p=153#comment-11514</guid>
		<description>&lt;a href=&quot;#comment-11512&quot; rel=&quot;nofollow&quot;&gt;@Evtim  &lt;/a&gt; 
I have to sort the dataProvider multiple times to assist with grouping items with certain traits. It&#039;s hard to explain without showing it to you, but I&#039;m not able to post it publically.

It&#039;s not about bringing elements to the top.

Except for one oddity where FlashPlayer appears to stop updating the width of elements (it&#039;s most likely my code), it seems to be working pretty much as I had hoped, however, your response above gives me concern as to my current approach.</description>
		<content:encoded><![CDATA[<p><a href="#comment-11512" rel="nofollow">@Evtim  </a><br />
I have to sort the dataProvider multiple times to assist with grouping items with certain traits. It&#8217;s hard to explain without showing it to you, but I&#8217;m not able to post it publically.</p>
<p>It&#8217;s not about bringing elements to the top.</p>
<p>Except for one oddity where FlashPlayer appears to stop updating the width of elements (it&#8217;s most likely my code), it seems to be working pretty much as I had hoped, however, your response above gives me concern as to my current approach.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Evtim</title>
		<link>http://evtimmy.com/2009/10/spark-layouts-with-flex-4-beta/comment-page-1/#comment-11512</link>
		<dc:creator>Evtim</dc:creator>
		<pubDate>Mon, 15 Mar 2010 05:27:17 +0000</pubDate>
		<guid isPermaLink="false">http://evtimmy.com/?p=153#comment-11512</guid>
		<description>Hi Jason,
I&#039;m not sure why are you sorting the dataProvider, but doing that from withing layout&#039;s updateDisplayList() doesn&#039;t seem quite right. As soon as you change the dataProvider, the DataGroup will mark itemRenderers as invalid or not in use and if they are requested later, they will be re-assigned to different items. In addition the DataGroup will be invalidated and this will trigger a second layout pass. If in that second pass your layout keeps re-sorting the dataProvider, you may end up with an infinite loop...
Now I wonder why do you sort the dataProvider, is it because you want to render different elements on top? If so, then you should instead take advantage of the element&#039;s &quot;depth&quot; property to control rendering order. If you&#039;re sorting the dataProvider for some other reason, then you should do it before the layout&#039;s updateDisplayList() is called. Think of the layout as the view for your data model - it should only reflect the current state of the data model without modifying it. Hope this helps!</description>
		<content:encoded><![CDATA[<p>Hi Jason,<br />
I&#8217;m not sure why are you sorting the dataProvider, but doing that from withing layout&#8217;s updateDisplayList() doesn&#8217;t seem quite right. As soon as you change the dataProvider, the DataGroup will mark itemRenderers as invalid or not in use and if they are requested later, they will be re-assigned to different items. In addition the DataGroup will be invalidated and this will trigger a second layout pass. If in that second pass your layout keeps re-sorting the dataProvider, you may end up with an infinite loop&#8230;<br />
Now I wonder why do you sort the dataProvider, is it because you want to render different elements on top? If so, then you should instead take advantage of the element&#8217;s &#8220;depth&#8221; property to control rendering order. If you&#8217;re sorting the dataProvider for some other reason, then you should do it before the layout&#8217;s updateDisplayList() is called. Think of the layout as the view for your data model &#8211; it should only reflect the current state of the data model without modifying it. Hope this helps!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason</title>
		<link>http://evtimmy.com/2009/10/spark-layouts-with-flex-4-beta/comment-page-1/#comment-11509</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Wed, 10 Mar 2010 18:37:09 +0000</pubDate>
		<guid isPermaLink="false">http://evtimmy.com/?p=153#comment-11509</guid>
		<description>&lt;a href=&quot;#comment-11507&quot; rel=&quot;nofollow&quot;&gt;@Jason  &lt;/a&gt; 
I can do a nested loop to compare a uniqueID from the DataProvider to the itemRenderer.data.uniqueID, and everything is positioned and displays correctly. I&#039;m not particularly fond of nested looping, but sometimes it&#039;s necessary. Any better ideas?</description>
		<content:encoded><![CDATA[<p><a href="#comment-11507" rel="nofollow">@Jason  </a><br />
I can do a nested loop to compare a uniqueID from the DataProvider to the itemRenderer.data.uniqueID, and everything is positioned and displays correctly. I&#8217;m not particularly fond of nested looping, but sometimes it&#8217;s necessary. Any better ideas?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

