Friday, April 20, 2012

Testing a Flex App for the iPad3 (part 2)



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">

4 comments:

  1. 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.

    In your case should the CustomRuntineDPIProvider Class be located as: amdexpenser/utils/CustomRuntimeDPIProvider.as

    Is that right?

    ReplyDelete
    Replies
    1. 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
      package amdexpenser.utils

      That's my bad. :)

      Delete
    2. updated the example code. Under the current example the CustomRuntimeDPIProvider class would be at src/com/dougmccluer/CustomRuntimeDPIProvider.as

      Delete
  2. It is widespread that on-line casinos supply barely greater odds and payback percentages than land-based casinos. AppLive bettingStreamingSame game parlayRefer a good friend bonus✔✔✔✔✔FanDuel is a fantasy sports operator that Maryland gamers can wager real cash on proper now. However, they're also a fully-fledged on-line sportsbook and appear set to be able to|to have the power to} supply authorized on-line sports betting as soon because the regulations are finalized. AppLive bettingStreamingSame game parlayRefer a good friend bonus✔✔✔✔✔Players in Maryland are place to} wager real cash on fantasy sports via DraftKings proper 바카라 now. However, all indications are that DraftKings may also be licensed to offer their sportsbook to gamers when the authorized on-line sports betting regulations are finally confirmed in Fall 2022. Internet gambling is far more constrained within the context in which a device can be used than cell gambling.

    ReplyDelete