While there are many times in which we will need to store specific application parameters in the case that our session is interrupted by other device functions (such as an incoming phone call), the mobile Flex framework does provide a good level of session preservation, which can be handled automatically for us.
Instruct Flex to preserve application state for us automatically by enabling persistNavigatorState:
1. We will first set up a new mobile Flex project with two views, these we simply call
first
andsecond
. Our initialViewNavigatorApplication
file will appear as such:<?xml version="1.0" encoding="utf-8"?> <s:ViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/ 2009" xmlns:s="library://ns.adobe.com/flex/spark" firstView="views.first"> </s:ViewNavigatorApplication>
2. Add a button to our
first
view that will enable us to push thesecond
view from there:<s:Button label="Engage Second State...