ActionScript® 3.0 Reference for the Adobe® Flash® Platform
Home  |  Show Packages and Classes List |  Packages  |  Classes  |  What's New  |  Index  |  Appendixes
mx.core 

RuntimeDPIProvider  - AS3 Flex

Packagemx.core
Classpublic class RuntimeDPIProvider
InheritanceRuntimeDPIProvider Inheritance Object

Language Version: ActionScript 3.0
Product Version: Flex 4.5
Runtime Versions: Flash Player 10, AIR 2.5

The RuntimeDPIProvider class provides the default mapping of similar device DPI values into predefined DPI classes. An Application may have its runtimeDPIProvider property set to a subclass of RuntimeDPIProvider to override Flex's default mappings. Overriding Flex's default mappings will cause changes in the Application's automatic scaling behavior.

Overriding Flex's default mappings is usually only necessary for devices that incorrectly report their screenDPI and for devices that may scale better in a different DPI class.

Flex's default mappings are:

160 DPI<200 DPI
240 DPI>=200 DPI and <280 DPI
320 DPI>=280 DPI

Subclasses of RuntimeDPIProvider should only depend on runtime APIs and should not depend on any classes specific to the Flex framework except mx.core.DPIClassification.

View the examples

More examples

Related API Elements



Public Properties
 PropertyDefined By
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  runtimeDPI : Number
[read-only] Returns the runtime DPI of the current device by mapping its flash.system.Capabilities.screenDPI to one of several DPI values in mx.core.DPIClassification.
RuntimeDPIProvider
Public Methods
 MethodDefined By
  
Constructor.
RuntimeDPIProvider
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
Returns the string representation of this object, formatted according to locale-specific conventions.
Object
 Inherited
Returns the string representation of the specified object.
Object
 Inherited
Returns the primitive value of the specified object.
Object
Property Detail

runtimeDPI

property
runtimeDPI:Number  [read-only]

Language Version: ActionScript 3.0
Product Version: Flex 4.5
Runtime Versions: Flash Player 10, AIR 2.5

Returns the runtime DPI of the current device by mapping its flash.system.Capabilities.screenDPI to one of several DPI values in mx.core.DPIClassification. A number of devices can have slightly different DPI values and Flex maps these into the several DPI classes. Flex uses this method to calculate the current DPI value when an Application authored for a specific DPI is adapted to the current one through scaling.



Implementation
    public function get runtimeDPI():Number

Related API Elements

Constructor Detail

RuntimeDPIProvider

()Constructor
public function RuntimeDPIProvider()

Language Version: ActionScript 3.0
Product Version: Flex 4.5
Runtime Versions: Flash Player 10, AIR 2.5

Constructor.

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