Flex Chronicles: Part 3 – childrenCreated & show

When you have a component inside a TabNavigator (I believe this applies to a ViewStack as well) (ViewStack’s show DOES get called it seems the first time… or maybe it’s because the TabNavigator is inside a ViewStack ::shrugs::), you can use the tried and true childrenCreated event to do initialization, since just like onLoad in Flash, it runs a frame after everything is setup, allowing you access child components. However, it only gets fired once. In the case of a component you want to reset itself each time it gets shown in a TabNavigator, you can use the “show” event. It gets fired once when the component is shown. The cool thing is, it does not get fired the first time the component is shown.

I had a component that shows blog entries. Upon being initialized, it’d call a webservice. However, this was only getting called once; I couldn’t call it remotely, because the call wouldn’t work the first time… since the component isn’t initiliazed the first time. Sooo, I was like…uh…wtf. Initialize called too early. Now, I just put my getEntries function call in both childrenCreated and show, and it works great!