When testing a Flex app for the iPad3, you'll want to create a custom RuntimeDPIProvider so that the app scales to the correct size. The Adobe docs describe how to subclass RuntimeDPIProvider at http://help.adobe.com/en_US/flex/mobileapps/WS19f279b149e7481c682e5a9412cf5976c17-8000.html#WS19f279b149e7481c-2a25e9b212d622ff5e8-8000
Using the following class will ensure the app is sized correctly on the device (using both slow and fast compile methods) and when previewing on the desktop.
package com.dougmccluer
{
import flash.system.Capabilities;
import mx.core.DPIClassification;
import mx.core.RuntimeDPIProvider;
public class CustomRuntimeDPIProvider extends RuntimeDPIProvider
{
public function CustomRuntimeDPIProvider()
{
super();
}
override public function get runtimeDPI():Number
{
if(Capabilities.os.indexOf("iPad")>-1)
{
if(Capabilities.screenResolutionX > 1500)
{
return DPIClassification.DPI_320;
}
}
return DPIClassification.DPI_160;
}
}
}
You just need to tell the application to use the custom runtime provider and set the application dpi to 320.s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" applicationDPI="320" runtimeDPIProvider="com.dougmccluer.CustomRuntimeDPIProvider">
Hi, Thanks for the post, I'm struggling a little with getting this to work. Just to make sure I'm not being a complete idiot.
ReplyDeleteIn your case should the CustomRuntineDPIProvider Class be located as: amdexpenser/utils/CustomRuntimeDPIProvider.as
Is that right?
You are correct. That should be the path within the src folder. BUT, that means I should amend the first line of the code to be
Deletepackage amdexpenser.utils
That's my bad. :)
updated the example code. Under the current example the CustomRuntimeDPIProvider class would be at src/com/dougmccluer/CustomRuntimeDPIProvider.as
Delete