{"id":4016,"date":"2012-12-13T17:38:31","date_gmt":"2012-12-13T13:38:31","guid":{"rendered":"http:\/\/blog.denivip.ru\/?p=4016"},"modified":"2013-08-05T14:10:37","modified_gmt":"2013-08-05T10:10:37","slug":"multiscreen-support-in-mobile-air-applications","status":"publish","type":"post","link":"http:\/\/blog.denivip.ru\/index.php\/2012\/12\/multiscreen-support-in-mobile-air-applications\/?lang=en","title":{"rendered":"Multiscreen Support in Mobile AIR Applications"},"content":{"rendered":"<p align=\"center\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.denivip.ru\/wp-content\/uploads\/2012\/12\/multiscreen.jpg\" alt=\"\" title=\"multiscreen\" width=\"450\" height=\"335\" class=\"aligncenter size-full wp-image-3835\" srcset=\"http:\/\/blog.denivip.ru\/wp-content\/uploads\/2012\/12\/multiscreen.jpg 450w, http:\/\/blog.denivip.ru\/wp-content\/uploads\/2012\/12\/multiscreen-300x223.jpg 300w\" sizes=\"(max-width: 450px) 100vw, 450px\" \/><\/p>\n<p>As AIR applications can run on multiple platforms and devices, AIR based developers have to take into account a vast diversity of screens, their resolutions and DPIs.  Despite a broad diversity of supported platforms, in this post we will focus on multiscreen development for mobile AIR applications based on the Flex framework. <!--more--><\/p>\n<p>Let&#8217;s now agree upon the basic terminology that we are going to use here. For convenience, in parentheses we will indicate the property containing a numerical value of a given parameter.<\/p>\n<ol>\n<li><strong>Screen resolution<\/strong> means the number of pixels on the screen in horizontal and vertical dimensions (<code class=\"codecolorer text default\"><span class=\"text\">Capabilities.screenResolutionX<\/span><\/code> and <code class=\"codecolorer text default\"><span class=\"text\">Capabilities.screenResolutionY<\/span><\/code>)<\/li>\n<li><strong>Display space resolution<\/strong> means both horizontal and vertical pixels of the display space. It may differ much from <strong>screen resolution<\/strong> as it does not include the status bar at the top, the button bar at the bottom, and also due to auto-scaling (<code class=\"codecolorer text default\"><span class=\"text\">systemManager.screen.width<\/span><\/code> and <code class=\"codecolorer text default\"><span class=\"text\">systemManager.screen.height<\/span><\/code>).<\/li>\n<li><strong>Screen DPI <\/strong> means the physical number of dots per inch on the device screen running the application (<code class=\"codecolorer text default\"><span class=\"text\">Capabilities.screenDPI<\/span><\/code>).<\/li>\n<li><strong>Runtime DPI <\/strong> returns <strong>Screen DPI<\/strong> rounded up to the value of one of the constants defined in the class called <code class=\"codecolorer text default\"><span class=\"text\">DPIClassification<\/span><\/code> (<code class=\"codecolorer text default\"><span class=\"text\">runtimeDPI<\/span><\/code> property) in the main class of the Flex application. The value of this property can be retrieved using <code class=\"codecolorer text default\"><span class=\"text\">FlexGlobals.topLevelApplication.runtimeDPI<\/span><\/code>). This property can only take three values: <code class=\"codecolorer text default\"><span class=\"text\">160, 240, 320<\/span><\/code>. These are the basic values to which <strong>DPI screen<\/strong> is rounded. You have to use fixed values to have a limited set of graphics for three different DPIs. Using the <code class=\"codecolorer text default\"><span class=\"text\">runtimeDPIProvider<\/span><\/code> property, you can specify, for the main application, a class inherited from <code class=\"codecolorer text default\"><span class=\"text\">RuntimeDPIProvider<\/span><\/code>. In this class, you can override the <code class=\"codecolorer text default\"><span class=\"text\">runtimeDPI<\/span><\/code> method and set your own logic to round up <strong>Screen DPI<\/strong> to the desired value of <strong>DPI runtime.<\/strong> This might be useful, for example, in the event in the addition to screen DPI you need to define its resolution or any other options.<\/li>\n<li><strong>Application DPI<\/strong> means a numeric DPI value for which the application is developed (property &#8212; <code class=\"codecolorer text default\"><span class=\"text\">applicationDPI<\/span><\/code>) in the main class of the Flex application. The value of this property can be accessed via <code class=\"codecolorer text default\"><span class=\"text\">FlexGlobals.topLevelApplication.applicationDPI<\/span><\/code>). This is the key property used during automatic scaling performed by the Flex framework. You can set this value can using MXML in the main application class, and can change it at runtime. If <code class=\"codecolorer text default\"><span class=\"text\">applicationDPI<\/span><\/code> is not specified, automatic scaling will not be performed by the Flex framework. This property can only take three values: <code class=\"codecolorer text default\"><span class=\"text\">160, 240, 320<\/span><\/code>.<\/li>\n<\/ol>\n<h3>Automatic Scaling<\/h3>\n<p>Auto-scaling using the Flex framework can be enabled by setting <strong>Application DPI<\/strong>. If the developer has specified <code class=\"codecolorer text default\"><span class=\"text\">applicationDPI<\/span><\/code>, then Flex begins to apply a scaling factor to the main application by changing <code class=\"codecolorer text default\"><span class=\"text\">scaleX<\/span><\/code> and <code class=\"codecolorer text default\"><span class=\"text\">scaleY<\/span><\/code> for <code class=\"codecolorer text default\"><span class=\"text\">systemManager<\/span><\/code>. This facilitates development of multi-platform and multi-screen applications.<\/p>\n<p>When developing applications with auto-scaling enabled, it is essential to define the size of display space. To do this, use <code class=\"codecolorer text default\"><span class=\"text\">systemManager.screen.width<\/span><\/code> and <code class=\"codecolorer text default\"><span class=\"text\">systemManager.screen.height<\/span><\/code> only, rather than <code class=\"codecolorer text default\"><span class=\"text\">stage.width<\/span><\/code> and <code class=\"codecolorer text default\"><span class=\"text\">stage.height<\/span><\/code>.<\/p>\n<p>For instance, let&#8217;s take a device and an application run by it with the following parameters:<\/p>\n<ul>\n<li>runtimeDPI of the device is set to 320;<\/li>\n<li>applicationDPI is set to 240;<\/li>\n<li>screen resolution is 1280 x 720;<\/li>\n<\/ul>\n<p>Having launched the application on a device, we can see the following values of properties:<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:540px;\"><div class=\"text codecolorer\">stage.stageWidth: 720 <br \/>\nstage.stageHeight: 1230 <br \/>\nstage.fullScreenWidth: 720 <br \/>\nstage.fullScreenHeight: 1280 <br \/>\nCapabilities.screenDPI: 320 <br \/>\nCapabilities.screenResolutionX: 720 <br \/>\nCapabilities.screenResolutionY: 1280 <br \/>\nsystemManager.screen.width: 540 <br \/>\nsystemManager.screen.height: 922.5 <br \/>\nsystemManager.scaleX: 1.333333333333333 <br \/>\nsystemManager.scaleY: 1.333333333333333<\/div><\/div>\n<p>You can see that the display space size is smaller than the stage size, because automatic scaling results in change of <code class=\"codecolorer text default\"><span class=\"text\">scaleX<\/span><\/code> and <code class=\"codecolorer text default\"><span class=\"text\">scaleY<\/span><\/code> in the application&#8217;s <code class=\"codecolorer text default\"><span class=\"text\">systemManager<\/span><\/code>. So, for instance, when centering pop-ups and other functional elements that have to know exact display space sizes, you can find the sizes in <code class=\"codecolorer text default\"><span class=\"text\">systemManager.screen.width<\/span><\/code> and <code class=\"codecolorer text default\"><span class=\"text\">systemManager.screen.height<\/span><\/code>.<\/p>\n<p>Automatic scaling can result in content distortion. To avoid this, please adhere to the following rules:<\/p>\n<ol>\n<li>Use vector images. In case of automatic scaling, Flex will display them similarly on all types of screens. Fonts also present no problem, as they are also scalable without distortion.<\/li>\n<li>For bitmaps, icons or skins you need to have images for three different DPIs. Flex has a number of in-built tools to use a needed image for a particular <strong>Runtime DPI.<\/strong><\/li>\n<\/ol>\n<h3>Customization of Bitmap Resources for Different DPIs<\/h3>\n<p>To ensure that bitmaps have no distortions and artifacts associated with automatic scaling of the application, you should define in Flex, which image should be used for a given DPI. To do this, when setting an image source, use an instance of <code class=\"codecolorer text default\"><span class=\"text\">MultiDPIBitmapSource<\/span><\/code>, whose properties contain image resources for three different DPI.<\/p>\n<p>Let&#8217;s consider several examples of bitmap customization.<br \/>\nHere is the class of component displaying a bell icon in a normal and selected state, respectively:<\/p>\n<div class=\"codecolorer-container actionscript3 default\" style=\"overflow:auto;white-space:nowrap;width:540px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<br \/>8<br \/>9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<br \/>25<br \/>26<br \/>27<br \/>28<br \/>29<br \/>30<br \/>31<br \/>32<br \/>33<br \/>34<br \/>35<br \/>36<br \/>37<br \/>38<br \/>39<br \/>40<br \/>41<br \/>42<br \/>43<br \/>44<br \/>45<br \/>46<br \/>47<br \/>48<br \/><\/div><\/td><td><div class=\"actionscript3 codecolorer\"><span class=\"kw4\">package<\/span> ru<span class=\"sy0\">.<\/span>denivip<span class=\"sy0\">.<\/span>europa<span class=\"sy0\">.<\/span>views<span class=\"sy0\">.<\/span>schedule <br \/>\n<span class=\"br0\">&#123;<\/span> <br \/>\n<span class=\"kw1\">import<\/span> spark<span class=\"sy0\">.<\/span>components<span class=\"sy0\">.<\/span>Group<span class=\"sy0\">;<\/span> <br \/>\n<span class=\"kw1\">import<\/span> spark<span class=\"sy0\">.<\/span>primitives<span class=\"sy0\">.<\/span>BitmapImage<span class=\"sy0\">;<\/span><br \/>\n<span class=\"kw1\">import<\/span> spark<span class=\"sy0\">.<\/span>utils<span class=\"sy0\">.<\/span>MultiDPIBitmapSource<span class=\"sy0\">;<\/span><br \/>\n<br \/>\n<span class=\"kw1\">public<\/span> <span class=\"kw4\">class<\/span> BellSwitcher <span class=\"kw1\">extends<\/span> Group <br \/>\n<span class=\"br0\">&#123;<\/span> <br \/>\n&nbsp; &nbsp; <span class=\"kw1\">private<\/span> <span class=\"kw2\">var<\/span> bellIcon<span class=\"sy0\">:<\/span>BitmapImage = <span class=\"kw1\">new<\/span> BitmapImage<span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<br \/>\n&nbsp; &nbsp; <span class=\"co1\">\/\/ Source for the icon in a normal state <\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">private<\/span> <span class=\"kw2\">var<\/span> multiSource<span class=\"sy0\">:<\/span>MultiDPIBitmapSource<span class=\"sy0\">;<\/span><br \/>\n<br \/>\n&nbsp; &nbsp; <span class=\"co1\">\/\/ Source for the icon in a selected state <\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">private<\/span> <span class=\"kw2\">var<\/span> multiSourceSelected<span class=\"sy0\">:<\/span>MultiDPIBitmapSource<span class=\"sy0\">;<\/span><br \/>\n<br \/>\n&nbsp; &nbsp; <span class=\"kw1\">public<\/span> <span class=\"kw3\">function<\/span> BellSwitcher<span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span> <br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#123;<\/span> <br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw1\">super<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">\/\/ For each of sources, set bitmap images <\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">\/\/ for three different DPIs<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; multiSource = <span class=\"kw1\">new<\/span> MultiDPIBitmapSource<span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span> <br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; multiSource<span class=\"sy0\">.<\/span>source160dpi = <span class=\"st0\">&quot;\/assets\/icon_bell@160.png&quot;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; multiSource<span class=\"sy0\">.<\/span>source240dpi = <span class=\"st0\">&quot;\/assets\/icon_bell@240.png&quot;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; multiSource<span class=\"sy0\">.<\/span>source320dpi = <span class=\"st0\">&quot;\/assets\/icon_bell@320.png&quot;<\/span><span class=\"sy0\">;<\/span><br \/>\n<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; multiSourceSelected = <span class=\"kw1\">new<\/span> MultiDPIBitmapSource<span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; multiSourceSelected<span class=\"sy0\">.<\/span>source160dpi = <span class=\"st0\">&quot;\/assets\/icon_bell_selected@160.png&quot;<\/span><span class=\"sy0\">;<\/span> <br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; multiSourceSelected<span class=\"sy0\">.<\/span>source240dpi = <span class=\"st0\">&quot;\/assets\/icon_bell_selected@240.png&quot;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; multiSourceSelected<span class=\"sy0\">.<\/span>source320dpi = <span class=\"st0\">&quot;\/assets\/icon_bell_selected@320.png&quot;<\/span><span class=\"sy0\">;<\/span><br \/>\n<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; addElement<span class=\"br0\">&#40;<\/span>bellIcon<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span> <br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; commitSelected<span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">private<\/span> <span class=\"kw2\">var<\/span> _selected<span class=\"sy0\">:<\/span><span class=\"kw5\">Boolean<\/span> = <span class=\"kw1\">false<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">public<\/span> <span class=\"kw3\">function<\/span> <span class=\"kw1\">set<\/span> selected<span class=\"br0\">&#40;<\/span><span class=\"kw7\">value<\/span><span class=\"sy0\">:<\/span><span class=\"kw5\">Boolean<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">:<\/span><span class=\"kw1\">void<\/span> <br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#123;<\/span> <br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; _selected = <span class=\"kw7\">value<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; commitSelected<span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">protected<\/span> <span class=\"kw3\">function<\/span> commitSelected<span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">:<\/span><span class=\"kw1\">void<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">\/\/ The icon source is determined based on the element state<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; bellIcon<span class=\"sy0\">.<\/span><span class=\"kw7\">source<\/span> = _selected <span class=\"sy0\">?<\/span> multiSourceSelected <span class=\"sy0\">:<\/span> multiSource<span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>An example of using <code class=\"codecolorer text default\"><span class=\"text\">MultiDPIBitmapSource<\/span><\/code> for bitmaps embedded in the application at compile time. Skin class for a CheckBox component:<\/p>\n<div class=\"codecolorer-container mxml default\" style=\"overflow:auto;white-space:nowrap;width:540px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<br \/>8<br \/>9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<br \/>25<br \/>26<br \/>27<br \/>28<br \/>29<br \/>30<br \/>31<br \/>32<br \/>33<br \/>34<br \/>35<br \/><\/div><\/td><td><div class=\"mxml codecolorer\"><span class=\"sc3\"><span class=\"coMULTI\">&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?--&gt;<\/span><\/span><br \/>\n<span class=\"sc3\"><span class=\"re1\">&lt;s:SparkSkin<\/span> xmlns:fx=<span class=\"st0\">&quot;http:\/\/ns.adobe.com\/mxml\/2009&quot;<\/span> xmlns:s=<span class=\"st0\">&quot;library:\/\/ns.adobe.com\/flex\/spark&quot;<\/span> xmlns:fb=<span class=\"st0\">&quot;http:\/\/ns.adobe.com\/flashbuilder\/2009&quot;<\/span> alpha.disabledStates=<span class=\"st0\">&quot;0.5&quot;<\/span><span class=\"re2\">&gt;<\/span><\/span><br \/>\n<br \/>\n&nbsp; &nbsp; <span class=\"sc3\"><span class=\"re1\">&lt;fx:Metadata<\/span><span class=\"re2\">&gt;<\/span><\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; \/** * @copy spark.skins.spark.ApplicationSkin#hostComponent *\/ [HostComponent(&quot;spark.components.CheckBox&quot;)]<br \/>\n&nbsp; &nbsp; <span class=\"sc3\"><span class=\"re1\">&lt;\/fx:Metadata<\/span><span class=\"re2\">&gt;<\/span><\/span> <br \/>\n&nbsp; &nbsp; <br \/>\n&nbsp; &nbsp; <span class=\"sc3\"><span class=\"re1\">&lt;s:states<\/span><span class=\"re2\">&gt;<\/span><\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"sc3\"><span class=\"re1\">&lt;s:State<\/span> name=<span class=\"st0\">&quot;up&quot;<\/span> <span class=\"re2\">\/&gt;<\/span><\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"sc3\"><span class=\"re1\">&lt;s:State<\/span> name=<span class=\"st0\">&quot;over&quot;<\/span> stateGroups=<span class=\"st0\">&quot;overStates&quot;<\/span> <span class=\"re2\">\/&gt;<\/span><\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"sc3\"><span class=\"re1\">&lt;s:State<\/span> name=<span class=\"st0\">&quot;down&quot;<\/span> stateGroups=<span class=\"st0\">&quot;downStates&quot;<\/span> <span class=\"re2\">\/&gt;<\/span><\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"sc3\"><span class=\"re1\">&lt;s:State<\/span> name=<span class=\"st0\">&quot;disabled&quot;<\/span> stateGroups=<span class=\"st0\">&quot;disabledStates&quot;<\/span> <span class=\"re2\">\/&gt;<\/span><\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"sc3\"><span class=\"re1\">&lt;s:State<\/span> name=<span class=\"st0\">&quot;upAndSelected&quot;<\/span> stateGroups=<span class=\"st0\">&quot;selectedStates&quot;<\/span> <span class=\"re2\">\/&gt;<\/span><\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"sc3\"><span class=\"re1\">&lt;s:State<\/span> name=<span class=\"st0\">&quot;overAndSelected&quot;<\/span> stateGroups=<span class=\"st0\">&quot;overStates, selectedStates&quot;<\/span> <span class=\"re2\">\/&gt;<\/span><\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"sc3\"><span class=\"re1\">&lt;s:State<\/span> name=<span class=\"st0\">&quot;downAndSelected&quot;<\/span> stateGroups=<span class=\"st0\">&quot;downStates, selectedStates&quot;<\/span> <span class=\"re2\">\/&gt;<\/span><\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"sc3\"><span class=\"re1\">&lt;s:State<\/span> name=<span class=\"st0\">&quot;disabledAndSelected&quot;<\/span> stateGroups=<span class=\"st0\">&quot;disabledStates, selectedStates&quot;<\/span> <span class=\"re2\">\/&gt;<\/span><\/span><br \/>\n&nbsp; &nbsp; <span class=\"sc3\"><span class=\"re1\">&lt;\/s:states<\/span><span class=\"re2\">&gt;<\/span><\/span><br \/>\n<br \/>\n&nbsp; &nbsp; <span class=\"sc3\"><span class=\"re1\">&lt;s:BitmapImage<\/span> excludeFrom=<span class=\"st0\">&quot;selectedStates&quot;<\/span><span class=\"re2\">&gt;<\/span><\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"sc3\"><span class=\"re1\">&lt;s:source<\/span><span class=\"re2\">&gt;<\/span><\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"sc3\"><span class=\"re1\">&lt;s:MultiDPIBitmapSource<\/span><\/span><br \/>\n<span class=\"sc3\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source160dpi=<span class=\"st0\">&quot;@Embed(source='assets\/images\/ui\/check_box@160.png')&quot;<\/span><\/span><br \/>\n<span class=\"sc3\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source240dpi=<span class=\"st0\">&quot;@Embed(source='assets\/images\/ui\/check_box@240.png')&quot;<\/span><\/span><br \/>\n<span class=\"sc3\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source320dpi=<span class=\"st0\">&quot;@Embed(source='assets\/images\/ui\/check_box@320.png')&quot;<\/span><span class=\"re2\">\/&gt;<\/span><\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"sc3\"><span class=\"re1\">&lt;\/s:source<\/span><span class=\"re2\">&gt;<\/span><\/span><br \/>\n&nbsp; &nbsp; <span class=\"sc3\"><span class=\"re1\">&lt;\/s:BitmapImage<\/span><span class=\"re2\">&gt;<\/span><\/span><br \/>\n&nbsp; &nbsp; <span class=\"sc3\"><span class=\"re1\">&lt;s:BitmapImage<\/span> includeIn=<span class=\"st0\">&quot;selectedStates&quot;<\/span><span class=\"re2\">&gt;<\/span><\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"sc3\"><span class=\"re1\">&lt;s:source<\/span><span class=\"re2\">&gt;<\/span><\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"sc3\"><span class=\"re1\">&lt;s:MultiDPIBitmapSource<\/span><\/span><br \/>\n<span class=\"sc3\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source160dpi=<span class=\"st0\">&quot;@Embed(source='assets\/images\/ui\/check_box_checked@160.png')&quot;<\/span><\/span><br \/>\n<span class=\"sc3\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source240dpi=<span class=\"st0\">&quot;@Embed(source='assets\/images\/ui\/check_box_checked@240.png')&quot;<\/span><\/span><br \/>\n<span class=\"sc3\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source320dpi=<span class=\"st0\">&quot;@Embed(source='assets\/images\/ui\/check_box_checked@320.png')&quot;<\/span><span class=\"re2\">\/&gt;<\/span><\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"sc3\"><span class=\"re1\">&lt;\/s:source<\/span><span class=\"re2\">&gt;<\/span><\/span><br \/>\n&nbsp; &nbsp; <span class=\"sc3\"><span class=\"re1\">&lt;\/s:BitmapImage<\/span><span class=\"re2\">&gt;<\/span><\/span><br \/>\n<span class=\"sc3\"><span class=\"re1\">&lt;\/s:SparkSkin<\/span><span class=\"re2\">&gt;<\/span><\/span><\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<h3>Use of Style Sheets Linked to DPI<\/h3>\n<p>Flex also lets you customize style sheets depending on the <strong>runtime DPI<\/strong> and operating system type. If you need, for instance, to set font size for a particular DPI or operating system, you can explicitly specify it in the style sheet, using the <code class=\"codecolorer text default\"><span class=\"text\">@media<\/span><\/code> rule. This rule can have two properties: <code class=\"codecolorer text default\"><span class=\"text\">os-platform<\/span><\/code> specifying the type of the Operating System and <code class=\"codecolorer text default\"><span class=\"text\">application-dpi<\/span><\/code> allowing you to specify styles for the needed DPI.<\/p>\n<p>The <code class=\"codecolorer text default\"><span class=\"text\">os-platform<\/span><\/code> property can have the following values:<\/p>\n<ul>\n<li><code class=\"codecolorer text default\"><span class=\"text\">Android<\/span><\/code><\/li>\n<li><code class=\"codecolorer text default\"><span class=\"text\">iOS<\/span><\/code><\/li>\n<li><code class=\"codecolorer text default\"><span class=\"text\">Macintosh<\/span><\/code><\/li>\n<li><code class=\"codecolorer text default\"><span class=\"text\">Linux<\/span><\/code><\/li>\n<li><code class=\"codecolorer text default\"><span class=\"text\">QNX<\/span><\/code><\/li>\n<li><code class=\"codecolorer text default\"><span class=\"text\">Windows<\/span><\/code><\/li>\n<\/ul>\n<p>The syntax of <code class=\"codecolorer text default\"><span class=\"text\">@media<\/span><\/code> can be quite complex and list different features and their combinations separated by commas.<\/p>\n<p>Here are several examples of <code class=\"codecolorer text default\"><span class=\"text\">@media<\/span><\/code> rules and its properties <code class=\"codecolorer text default\"><span class=\"text\">os-platform<\/span><\/code> and <code class=\"codecolorer text default\"><span class=\"text\">application-dpi<\/span><\/code>:<\/p>\n<div class=\"codecolorer-container actionscript3 default\" style=\"overflow:auto;white-space:nowrap;width:540px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<br \/>8<br \/>9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<br \/>25<br \/>26<br \/>27<br \/>28<br \/>29<br \/>30<br \/>31<br \/>32<br \/>33<br \/>34<br \/><\/div><\/td><td><div class=\"actionscript3 codecolorer\"><span class=\"coMULTI\">\/* Any operating system and 160 DPI *\/<\/span> <br \/>\n@media <span class=\"br0\">&#40;<\/span>application<span class=\"sy0\">-<\/span>dpi<span class=\"sy0\">:<\/span> <span class=\"nu0\">160<\/span><span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; s<span class=\"sy0\">|<\/span>Button <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw7\">fontSize<\/span><span class=\"sy0\">:<\/span> <span class=\"nu0\">10<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><br \/>\n<br \/>\n<span class=\"co2\">\/* Only iOS and 240 DPI *\/<\/span> <br \/>\n@media <span class=\"br0\">&#40;<\/span>application<span class=\"sy0\">-<\/span>dpi<span class=\"sy0\">:<\/span> <span class=\"nu0\">240<\/span><span class=\"br0\">&#41;<\/span> and <span class=\"br0\">&#40;<\/span>os<span class=\"sy0\">-<\/span>platform<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;IOS&quot;<\/span><span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; s<span class=\"sy0\">|<\/span>Button <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw7\">fontSize<\/span><span class=\"sy0\">:<\/span> <span class=\"nu0\">11<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span> <br \/>\n<span class=\"br0\">&#125;<\/span><br \/>\n<br \/>\n<span class=\"co2\">\/* iOS at 160 DPI or Android at 160 DPI *\/<\/span> <br \/>\n@media <span class=\"br0\">&#40;<\/span>os<span class=\"sy0\">-<\/span>platform<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;IOS&quot;<\/span><span class=\"br0\">&#41;<\/span> and <span class=\"br0\">&#40;<\/span>application<span class=\"sy0\">-<\/span>dpi<span class=\"sy0\">:<\/span> <span class=\"nu0\">160<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">,<\/span> <span class=\"br0\">&#40;<\/span>os<span class=\"sy0\">-<\/span>platform<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;ANDROID&quot;<\/span><span class=\"br0\">&#41;<\/span> and <span class=\"br0\">&#40;<\/span>application<span class=\"sy0\">-<\/span>dpi<span class=\"sy0\">:<\/span> <span class=\"nu0\">160<\/span><span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; s <span class=\"sy0\">|<\/span> Button <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw7\">fontSize<\/span><span class=\"sy0\">:<\/span> <span class=\"nu0\">13<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span> <br \/>\n<span class=\"br0\">&#125;<\/span><br \/>\n<br \/>\n<span class=\"sy0\">\/<\/span> <span class=\"sy0\">*<\/span> Any OS except Android at <span class=\"nu0\">240<\/span> DPI <span class=\"sy0\">*\/<\/span> <br \/>\n@media not all and <span class=\"br0\">&#40;<\/span>application<span class=\"sy0\">-<\/span>dpi<span class=\"sy0\">:<\/span> <span class=\"nu0\">240<\/span><span class=\"br0\">&#41;<\/span> and <span class=\"br0\">&#40;<\/span>os<span class=\"sy0\">-<\/span>platform<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;Android&quot;<\/span><span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; s<span class=\"sy0\">|<\/span>Button <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw7\">fontSize<\/span><span class=\"sy0\">:<\/span> <span class=\"nu0\">12<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span> <br \/>\n<span class=\"br0\">&#125;<\/span><br \/>\n<br \/>\n<span class=\"co2\">\/* Any OS except iOS at any DPI *\/<\/span><br \/>\n@media not all and <span class=\"br0\">&#40;<\/span>os<span class=\"sy0\">-<\/span>platform<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;IOS&quot;<\/span><span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; s<span class=\"sy0\">|<\/span>Button <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw7\">fontSize<\/span><span class=\"sy0\">:<\/span> <span class=\"nu0\">14<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<h3>Automatic Scaling<\/h3>\n<p>To disable auto-scaling (or rather not to enable it), please do not specify <strong>Application DPI<\/strong> in property <code class=\"codecolorer text default\"><span class=\"text\">applicationDPI<\/span><\/code> in the main class.<\/p>\n<p>When Automatic Scaling is disabled in Flex, you have to re-size interface and design elements yourself. For images, you can use customization of bitmap resources that we have already mentioned above. <\/p>\n<p>Using style sheets for each DPI value, you can customize font size, icon types and other parameters depending on the device screen. If auto-scaling is disabled, <code class=\"codecolorer text default\"><span class=\"text\">applicationDPI<\/span><\/code> will be set to <code class=\"codecolorer text default\"><span class=\"text\">runtimeDPI<\/span><\/code>. Therefore, when using styles with auto-scaling disabled, <strong>Runtime DPI<\/strong> will be linked.<\/p>\n<p>Flex has a fairly extensive toolkit to develop multi-platform and multi-screen applications, almost eliminating development routine. Auto-scaling offers great benefits and allows you to develop applications faster and be sure that they will look perfect on various devices.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As AIR applications can run on multiple platforms and devices, AIR based developers have to take into account a vast diversity of screens, their resolutions and DPIs. Despite a broad diversity of supported platforms, in this post we will focus on multiscreen development for mobile AIR applications based on the Flex framework.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[455,451,355,20,407],"tags":[198,523,408,521,474,522,448,484],"_links":{"self":[{"href":"http:\/\/blog.denivip.ru\/index.php\/wp-json\/wp\/v2\/posts\/4016"}],"collection":[{"href":"http:\/\/blog.denivip.ru\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.denivip.ru\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.denivip.ru\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.denivip.ru\/index.php\/wp-json\/wp\/v2\/comments?post=4016"}],"version-history":[{"count":18,"href":"http:\/\/blog.denivip.ru\/index.php\/wp-json\/wp\/v2\/posts\/4016\/revisions"}],"predecessor-version":[{"id":4838,"href":"http:\/\/blog.denivip.ru\/index.php\/wp-json\/wp\/v2\/posts\/4016\/revisions\/4838"}],"wp:attachment":[{"href":"http:\/\/blog.denivip.ru\/index.php\/wp-json\/wp\/v2\/media?parent=4016"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.denivip.ru\/index.php\/wp-json\/wp\/v2\/categories?post=4016"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.denivip.ru\/index.php\/wp-json\/wp\/v2\/tags?post=4016"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}