RSS

Store data in AIR applications for iOS devices

11 Nov

Saving state on iOS devices

We envisioned the scenario of applications that lose data when they are interrupted. Of course, the built-in iOS apps don’t do that—when you go back to your text messages after that interrupting phone call, you pick up right where you left off. This is done by the simple expedient of saving state when the application is ordered to quit by the OS. In the Objective-C world, you will have to implement this yourself (see the appropriate section of the iOS Application Programming Guide), and it is no different when you are developing with Flash.

Saving on exit

How do you know when to save in Flash? Since AIR applications for iOS share the same API as AIR apps for Adobe AIR, you can listen for the NativeApplication.EXITING event to know when to save your state:

package 
{
    import flash.desktop.NativeApplication;
    import flash.display.Sprite;
    import flash.events.Event;

    public class Save1 extends Sprite
    {
        public function Save1()
        {
            // Listen for exiting event.   
            NativeApplication.nativeApplication.addEventListener(Event.EXITING, onExit);

            // Load data.           ;
            load();
        }
        private function onExit(e:Event):void
        {
            trace("Save here.");
        }

        private function load():void
        {
            trace("Load here.");
        }

    }
}
Read more : http://www.adobe.com/devnet/flash/articles/saving_state_air_apps.html
Advertisements
 
Leave a comment

Posted by on November 11, 2011 in Action Script3, Adobe Air, iPhone

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: