Developing Android Applications with Adobe AIR [101]
By default, a ViewTransition animates between screens, where one view slides out and the other slides in, defined as SlideViewTransition. You can change it for one of the following transitions: CrossFadeViewTransition, FlipViewTransition, or ZoomViewTransition.
The default transition can be changed in navigator.defaultPopTransition and navigator.defaultPushTransition:
import spark.transitions.CrossFadeViewTransition;
import spark.transitions.FlipViewTransition;
var pushTransition = new FlipViewTransition();
navigator.defaultPushTransition = pushTransition;
var popTransition = new CrossFadeViewTransition();
navigator.defaultPopTransition = popTransition;
// OR
private function onClick(event:MouseEvent):void {
navigator.pushView(HomeView, {}, FlipViewTransition);
}
To suppress the transition altogether, enter the following in the Default Application file:
navigator.transitionEnabled = false;
// OR
ViewNavigator.defaultPushTransition = null;
ViewNavigator.defaultPopTransition = null;
A default ActionBar control is placed at the top of the screen. It functions as a control and navigation menu and provides contextual information, such as the current active view. It has a navigation area, a control area, and an action area. To modify it, use the navigationContent, titleContent, and actionContent tags.
By default, the name of the active view shows in the titleContent. To add a button to the navigationContent tag to go back home, use:
private function goHome():void {
navigator.popToFirstView();
}
If you use it, move all navigation functionality from the views to it. Alternatively, you can choose not to use it at all. To hide it at the view level, use the following:
actionBarVisible = false;
To hide it at the application level, use this code:
navigator.actionBar.visible = false;
navigator.actionBar.includeInLayout = false;
Pressing the back button automatically goes back to the previous view. To overwrite this functionality, set a null navigationContent as follows:
If the user leaves the application on a specific view, you can start the application again on the same view with the same data by using the sessionCachingEnabled tag:
xmlns:s="library://ns.adboec.com/flex/spark" sessionCachingEnabled="true" firstView="views.OpeningView" } } Conclusion You now have the fundamentals to create the view and navigation components of your application, whether you choose to write pure ActionScript or develop a Flex mobile application. Once your views are in place, you can dive into the workings of your application functionality. In the next chapter, we will develop a complete application using many of the APIs we covered previously. Chapter 17. Case Study You live and learn. At any rate, you live. —Douglas Noel Adams The Album is a project composed of two AIR applications, one for mobile and one for the desktop. It covers many of the APIs we have discussed in other chapters, and it is meant to be an overview of the book so that you can see how much you have learned. The Album Application In the desktop version, the user can see an image at full resolution on a large screen. It can be saved to the desktop, and it can also be edited and uploaded to a photo service. NOTE Thanks to Mihai Corlan for his original idea which I expanded for this case study: http://corlan.org/2010/07/08/androidpictures-or-how-to-share-phone-pictures-with-desktops/. Please download the two applications
In the mobile version of the AIR application, the user takes a picture or pulls one from the camera roll. She can save it to a dedicated database, along with an audio caption and geolocation information. The group of saved images is viewable in a scrollable menu. Images can be sent from the device to the desktop via a wireless network.