在Flex mobile中开发时如何区分手机和平板电脑?

Ale*_*ber 2 apache-flex flex4 flex4.5 flex-mobile flex4.6

我在Flex移动卡片游戏中使用applicationDPI:

<?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.Menu"
    applicationDPI="160"
    initialize="init()">

    <fx:Style source="Preferans.css" />

    <fx:Script>
        <![CDATA[
            import spark.core.ContentCache;
            public static const AVATAR_CACHE:ContentCache = new ContentCache();

            public static var SCALE:Number;

            public function init():void {
                SCALE = runtimeDPI / applicationDPI;
            }   
        ]]> 
    </fx:Script>
</s:ViewNavigatorApplication>
Run Code Online (Sandbox Code Playgroud)

并根据它提供3种不同分辨率的资产:

<fx:Declarations>
    <s:MultiDPIBitmapSource id="BACK"
        source160dpi="@Embed('assets/icons/low-res/back.png')"
        source240dpi="@Embed('assets/icons/mid-res/back.png')"
        source320dpi="@Embed('assets/icons/high-res/back.png')"/>
</fx:Declarations>
Run Code Online (Sandbox Code Playgroud)

当我在Flash Builder 4.6中选择一个iPad模拟器时,结果仍然不太好看:

在此输入图像描述

选择Google Nexus One会产生更好的效果:

在此输入图像描述

在这里做什么,用什么来检测手机与平板设备?

检查屏幕分辨率在这里没有帮助 - 请参阅上面的iPad示例(低分辨率,但大屏幕).

小智 6

  public static function get isTablet():Boolean  
    { 

       var deviceWidth:Number = Capabilities.screenResolutionX / Capabilities.screenDPI;

       var deviceHeight:Number = Capabilities.screenResolutionY / Capabilities.screenDPI;

       var diagonalInches:Number = Math.sqrt((deviceWidth * deviceWidth)+ (deviceHeight *    deviceHeight));
      if(diagonalInches>=7)
          return true;
      else
          return false;
    }
Run Code Online (Sandbox Code Playgroud)