The View class includes some new life cycle events specifically added for mobile applications. These events are important for application memory conservation:
- FlexEvent.VIEW_ACTIVATE is dispatched when the view has been activated:
viewActivate=”view1_viewActivateHandler(event)” - FlexEvent.VIEW_DEACTIVATE is dispatched when the view has been deactivated:
viewDeactivate=”view1_viewDeactivateHandler(event)” - FlexEvent.REMOVING is dispatched right before FlexEvent.VIEW_DEACTIVATE, when the view is about to be deactivated. Calling preventDefault() will cancel the screen change.
Although this life cycle is great for keeping the application’s memory usage minimal, the default behavior to deactivate a view also destroys any data associated with that view. To preserve data so that it will be available if the user returns to that view, you can save the data to the View.data property.
If you would like to prevent a view from ever being deactivated, you can set the destruc tionPolicy attribute of the view (which normally defaults to auto) to never:
destructionPolicy=”never”