| 包 | mx.core |
| 类 | public class RuntimeDPIProvider |
| 继承 | RuntimeDPIProvider Object |
| 语言版本: | ActionScript 3.0 |
| 产品版本: | Flex 4.5 |
| 运行时版本: | Flash Player 10, AIR 2.5 |
对于错误报告其 screenDPI 的设备和可能在不同 DPI 类中更好进行缩放的设备,通常才需要覆盖 Flex 的默认映射。
Flex 的默认映射为:
| 160 DPI | <200 DPI |
| 240 DPI | >=200 DPI 和 <280 DPI |
| 320 DPI | >=280 DPI |
RuntimeDPIProvider 的子类应仅依赖于运行时 API,且不应依赖于特定于 Flex 框架的任意类(除 mx.core.DPIClassification 之外)。
相关 API 元素
公共属性
| 属性 | 由以下参数定义 | ||
|---|---|---|---|
![]() | constructor : Object
对类对象或给定对象实例的构造函数的引用。 | Object | |
| runtimeDPI : Number [只读]
通过将其 flash.system.Capabilities.screenDPI 映射至 mx.core.DPIClassification 中几个 DPI 值之一,返回当前设备的运行时 DPI。 | RuntimeDPIProvider | ||
公共方法
| 方法 | 由以下参数定义 | ||
|---|---|---|---|
构造函数。 | RuntimeDPIProvider | ||
![]() |
表示对象是否已经定义了指定的属性。 | Object | |
![]() |
表示 Object 类的实例是否在指定为参数的对象的原型链中。 | Object | |
![]() |
表示指定的属性是否存在、是否可枚举。 | Object | |
![]() |
设置循环操作动态属性的可用性。 | Object | |
![]() |
返回此对象的字符串表示形式,其格式设置遵守区域设置特定的约定。 | Object | |
![]() |
返回指定对象的字符串表示形式。 | Object | |
![]() |
返回指定对象的原始值。 | Object | |
属性详细信息
runtimeDPI | 属性 |
runtimeDPI:Number [只读] | 语言版本: | ActionScript 3.0 |
| 产品版本: | Flex 4.5 |
| 运行时版本: | Flash Player 10, AIR 2.5 |
通过将其 flash.system.Capabilities.screenDPI 映射至 mx.core.DPIClassification 中几个 DPI 值之一,返回当前设备的运行时 DPI。一些设备可以具有略有不同的 DPI 值且 Flex 将其映射至几个 DPI 类。当针对特定 DPI 而编写的应用程序通过缩放适应于当前方法时,Flex 使用该方法计算当前 DPI 值。
实现
public function get runtimeDPI():Number相关 API 元素
构造函数详细信息
RuntimeDPIProvider | () | 构造函数 |
public function RuntimeDPIProvider()| 语言版本: | ActionScript 3.0 |
| 产品版本: | Flex 4.5 |
| 运行时版本: | Flash Player 10, AIR 2.5 |
构造函数。
示例 如何使用本示例
RuntimeDPIProviderApp.mxml
<?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.RuntimeDPIProviderAppView"
applicationDPI="160" runtimeDPIProvider="RuntimeDPIProviderExample" >
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
</s:ViewNavigatorApplication>
RuntimeDPIProviderExample.as
package
{
import flash.system.Capabilities;
import mx.core.DPIClassification;
import mx.core.RuntimeDPIProvider;
public class RuntimeDPIProviderExample extends RuntimeDPIProvider
{
public function RuntimeDPIProviderExample()
{
}
override public function get runtimeDPI():Number
{
// A tablet reporting an incorrect DPI of 240.
if (Capabilities.screenDPI == 240 &&
Capabilities.screenResolutionX == 600 &&
Capabilities.screenResolutionY == 1024)
{
return DPIClassification.DPI_160;
}
return super.runtimeDPI;
}
}
}
RuntimeDPIProviderAppView.mxml
Tue Jun 12 2018, 11:04 AM Z
隐藏继承的公共属性
显示继承的公共属性