Wednesday, February 18, 2009

Flex Component Life Cycle - in my way

I have developed a few set of flex components and my friend Jorge wanted to know exactly what is happening inside it. This blog was also waiting for something for a long time. So, here it goes in my cooking way :D.
Can you try a last time explanation of what each step of the event flow is supposed to do?
createChildren - 
create all child components, don't give them any sizing information, just create, these are like ingredients for your component dish, you are gonna mix them up and bake them and serve it to eat :)
Each ingredient has some property, sweet/sour etc. you set how much is needed and for what. say button, user wants a long label (more sweet), assign them in commitProperties, use invalidation/validation model. 
You want to serve better right !, say you are making a drink, then it will have a specific quantity according to you the cook. You finalize that 300 ml is sufficient, if user wants more then S/he will take it or something. but 300 ml is what you decide. So each component need to have some specific size, if user supplies width/height then measure will not be called otherwise it will be called. :D
Now, updateDisplayList gets height/width from measure or from the user supplied. You don't want same quantity of salt in 100 ml, which you will give in 300 ml. So based on the height/width you get in updateDisplayList, draw them accordingly, more specifically cook it :D
Hope its clear and fun reading flex in this way.