R – Flex Component Lifecycle with Menus – best practice

actionscript-3apache-flex

I have built a multiplage application in Flex with different user roles. I use a View Stack with a Menu Bar to navigate between the different pages.

However – each time a page gets opened, I need to do some database calls, apply User Role settings, etc. in an init() function. This init function may reference some UI elements of this page.

I tried to load it with the "creationComplete" event, but this one gets only triggered once (since the page is not rebuilt each them the view stack shows it).

Now I have put it on the "show" event, but this seems not to get triggered consistently, or before the page is fully created the first time.

Whats the best practice for this case?
* I have to pass in data
* Call init functions (database calls)
* Manipulate components

Ideally I would need a way to call init each time the page is loaded and after all components are created.

Thanks for your help,
Martin

Best Answer

Just an idea but why not trying to do your remote call on ViewStack change effect. You could use an interface for this that your views implements.

Related Topic