Differences between [Inject] and [FastInject] tags

In order to illustrate the difference between [Inject] and [FastInject] we first need to know the difference between describeType and describeTypeJSON functions.

describeType:  The describeType() method returns an xml dump that contains all the details you’d ever need to know about any object that is passed in as a parameter. This method implements the programming concept of reflection API for the ActionScript language.

Ex: trace(flash.utils.describeType(flash.display.MovieClip));

Note: describeType() only shows public properties and methods, and will not show properties and methods that are private, package internal or in custom namespaces. If you need only to traverse an object’s inheritance hierarchy and do not need the other information provided by describeType(), use the getQualifiedClassName() and getQualifiedSuperclassName() functions instead.

More on this topic at http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/utils/package.html#describeType()

describeTypeJSON:  With this  method it’s possible to retrieve reflection data as an object and to filter certain types of information using the constants.

HIDE_NSURI_METHODS = 1
INCLUDE_BASES = 2
INCLUDE_INTERFACES = 4
INCLUDE_VARIABLES = 8
INCLUDE_ACCESSORS = 16
INCLUDE_METHODS = 32
INCLUDE_METADATA = 64
INCLUDE_CONSTRUCTOR = 128
INCLUDE_TRAITS = 256
USE_ITRAITS = 512
HIDE_OBJECT = 1024
FLASH10_FLAGS = 1535

Ex:
package avmplus
{
    public function getInterfaces(object:*):Array
    {
        return describeTypeJSON(object, INCLUDE_TRAITS | INCLUDE_INTERFACES).traits.interfaces;
    }
}

Note:  The describeTypeJSON is defined in the avmplus.* package and supported for Flash Player 10.1

More on this topic at http://www.tillschneidereit.de/2009/11/22/improved-reflection-support-in-flash-player-10-1/

[Inject] v/s [FastInject]:

Parsley has the ability of reflection API which reflects on all managed objects and reflection of components which is very expensive operation due to numerous number of properties,methods and events. Which means that Parsley   2.1 and below uses describeType() method on all of its manages objects. [Inject] tag uses the describeType() method to introspect its managed objects.

Introduced in Parsley 2.2, the [FastInject] tag is the key to the performance optimization. [FastInject] uses the describeTypeJSON() method which is faster than describeType(). Note that the impact of reflecting huge UIComponents is still high. Parsley maintains an internal reflection cache, so that each class is only processed once, but if you are using a high number of different component classes this may not help much.In a smaller application this effect is negligible but its a concern for larger applications.

<parsley:FastInject property="model" type="{MyPanelPM}" /> 
 
<parsley:FastInject injectionComplete="init();"> 
 <parsley:Inject property="model" type="{MyPanelPM}"/> 
 <parsley:Inject property="status" type="{MyApplicationStatus}"/> 
</parsley:FastInject>
 
Action Script:
function MyView () { 
 FastInject .view(this) 
 .property("pm") 
 .type(MyViewPM) 
 .complete(injectionComplete) 
 .execute(); 

 
private function injectionComplete () : void { /* ... */ }

Corrections:  describeType() and describeTypeJSON() are not included in Parsley framework, they are part of avmplus package of the Flash Player. describeTypeJSON is provided in Flash Player 10.1 and above.

reflection in fp 10.1

If the user runs the Flex Application built with Parsley framework against Flash Player’s versions 10.1 and above, Parsley intelligently uses the faster describeTypeJSON() and if the application is run against Flash Player versions below 10.1, Parsley uses  the slower describeType()

In reality, FastInject neither uses describeType() nor describeTypeJSON(). FastInject is used for injecting a managed object from the nearest Context in the view hierarchy into a view without reflecting on the view. This way the FastInject  retrieves a particular object from the IoC Container without actually getting wired to it to avoid the cost of reflection and hence its fast.

Sources:

http://www.spicefactory.org/parsley/docs/2.4/manual/?page=view&section=intro
http://www.tillschneidereit.de/2009/11/22/improved-reflection-support-in-flash-player-10-1/
http://www.scottgmorgan.com/blog/index.php/2007/10/22/say-hello-to-my-little-friend-describetype/

An answer to the most commonly asked question by most confused Flex Developers

About the item renderer and item editor life cycle

Flex creates instances of item renderers and item editors as needed by your application for display and measurement purposes. Therefore, the number of instances of an item renderer or item editor in your application is not necessarily directly related to the number of visible item renderers. Also, if the list control is scrolled or resized, a single item renderer instance may be reused to represent more than one data item. Thus, you should not make assumptions about how many instances of your item renderer and item editor are active at any time.

Because Flex can reuse an item renderer, ensure that you fully define its state. For example, you use a CheckBox control in an item renderer to display a true (checked) or false (unchecked) value based on the current value of the data property. A common mistake is to assume that the CheckBox control in the item renderer is always in its default state of unchecked. Developers then write an item renderer to inspect the data property for a value of true and set the CheckBox control to checked if found.

However, you must take into account that the CheckBox may already be checked. So, you must inspect the data property for a value of false, and explicitly uncheck the control if it is checked.

Source: http://livedocs.adobe.com/flex/3/html/help.html?content=cellrenderer_4.html