Using Capabilities
So far you have seen how to use CSS to control some of the visual
aspects of your application, but you may also wish to have only certain
pieces of your application available to target specific devices or
specific views created for specific devices. This is possible by utilizing
the properties of the Capabilities
class to determine
operating system, screen resolution, and so on. The example below will
serve a different home screen to the user depending on their device. This
technique will allow you to target specific
audiences with a custom experience. The firstView
property of the View
NavigatorApplication
is bound to a function
called getFirstView
, which evaluates the
Capabilities.version
, and returns a different view
based on the operating system (see Figures 7-6 and 7-7).
You could also use other properties of the
Capabilities
class in the same manner. You may wish to
look into Capabilities.screenDPI
,
Capabilities.screenResolutionX
, Capabilities.screenResolutionY
, and
Capabilities.screenColor
:
Note
I could also have had just one main view file, and simply set the state of that file to be different based on the operating system.
<?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="{getFirstView(Capabilities.version)}">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import ...
Get Developing iOS Applications with Flex 4.5 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.