views:

285

answers:

2

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

A: 

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.

PeZ
Yes thats what I wanted to do, but the first time, when the View was never accessed before, I can not reference the children of the View. They dont exist yet. Only the TabBar has the property having the children of a Container initialized once the ITEM.CLICK event is fired.But if u use a Viewstack with a Tabbar, this event is not supported.I now ended up dismissing deferred instantation, set it creationPolicy to "All" and make the calls on every view stack change.
Ok.I remember having issues with that kind of problem too. I don't own the source anymore but for what I can remember, I used both creationComplete and show effects. First time a view is created the creationComplete handler is executed call the init function and set a creationDone variable to true. In the show effect handler , check if creationDone is true, and if it is, call init
PeZ
A: 

Try updateComplete event.

Dispatched when an object has had its commitProperties(), measure(), and updateDisplayList() methods called (if needed).

This is the last opportunity to alter the component before it is displayed. All properties have been committed and the component has been measured and layed out.

zdmytriv
This event is fired to often, also even before the page is ever loaded.