TrexTroy
TrexTroy

Reputation: 303

flex validation invalidation (component life cycle)

I am still confused with Validation and Invalidation of the component in Flex. Could anybody please give me simple comparison about what Validation can do which invalidation cant and vice versa.

I really appreciate your any help.

Thanks.

Upvotes: 0

Views: 1187

Answers (1)

shaunhusain
shaunhusain

Reputation: 19748

Although I do agree with the comments, this is pretty well documented I think your just missing the overall relationship between "invalidation" and "validation" methods. Basically whenever you're making a call to invalidate somethings, whether it's the display list, the size, or the properties then all your doing is telling it to set a boolean flag for one of those (any time you modify a property that will modify any of these three it will call the appropriate invalidate method such as invalidateProperties when set width is called). When the next enter frame/render happens, it will check the flags and if any of them are set to invalid it calls the corresponding validation method (updateDisplayList, commitProperties, measure).

To see the code for yourself in FB/Eclipse hit Ctrl+Shift+T and pull up UIComponent, hit Ctrl+O once UIComponent.as is opened and type in validateNow you can see the method body is 1 line and there's a nice ASDoc comment there explaining what it does. Better yet you'll see it calls validateClient on a ILayoutManager, pop open LayoutManager (Ctrl+Shift+T again) look at validateClient, it explains basically what I do here.

I think this is where you're coming from because I was in that boat once too, not understanding the relationship between updating a property and it affecting it's siblings/parent/children but it's really key to reducing processing load since a property can be modified multiple times between frame refreshes and it doesn't need to re-calculate everything around it until it will actual be redrawn.

The problem being that sometimes you want to modify a property and immediately (that is on the next lines execution) be able to see how it's side affects have modified other parts of the layout, in this case you can call validateNow() after modifying a property forcing it to immediately update all of that even if it may happen multiple times before a redraw occurs. This is generally not a great practice since it usually means undesired cpu time is wasted, but sometimes it's the easiest option.

Upvotes: 1

Related Questions