Over a million developers have joined DZone.

Decreasing startup time of a Flex 4 application using virtualization: the three rules - Part I

DZone's Guide to

Decreasing startup time of a Flex 4 application using virtualization: the three rules - Part I

· Web Dev Zone ·
Free Resource

Jumpstart your Angular applications with Indigo.Design, a unified platform for visual design, UX prototyping, code generation, and app development.

I've spent several days presenting the new Flex 4 features for many of our enterprise clients. As it's simple to understand, most of the time is dedicated to the brand-new Flex 4 List based components. 

Spark List-based components bring a lot of new topics to consider when developing Flex 4 applications: the DataGroup container, virtualization, the dropdown list, custom item rendere and more.

One cool thing about DataGroup is that it supports virtual layouts. As each time I show this topic I get many questions, I've promised myself to write some posts to explain what a virtual layout is.

DataGroup container replaces Repeater container. Taht's a good move from Adobe because the Repeater often comes up with memory leaks.

Virtual layouts allows you to create only objects that need to be shown onscreen and to recycle item renders.  So it's just a matter of how item renderer are created and handled by the layout. 

For allowing a DataGroup to recycle item renderers there are 3 requirements that must match:

1. The useVirtualLayout  property set to "true"



<HorizontalLayout useVirtualLayout="true"/>



2. At least an itemRenderer specified and none itemRendererFunction used:

 <s:DataGroup dataProvider="{ myAC }" id="dataGroup" width="100%" height="100% itemRederer="renderer.myRenderer">

3. Instead of using data binding within the item renders,  use the override of the set data (not mandatory but highly recomended):

<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" 





override public function set data(value:Object):void


super.data = value;

if (value== null)

myText.selected = false;

myText.text = value.firstName.toString();





<s:State name="normal"/>

<s:State name="hovered"/>

<s:State name="selected"/>


<s:Rect left="0" right="0" top="0" bottom="0">


<s:SolidColor color="0xCEDBEF" color.hovered="0xA8C6EE" color.selected="0xCCCCCC" />



<s:RichText text="{ data.firstName }" horizontalCenter="0" />


As you can easily deduct, choosing to use a virtual layout could represent a huge performance gain when your dataProvider works with many items.

I want to add more info about his topic, and I'll write a new piece of information about that soon. In the meantime have a look at this examples:

Creating a recyclable item renderer

Note that the Spark List turns on virtual layout by default.

Take a look at an Indigo.Design sample application to learn more about how apps are created with design to code software.


Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}