If you are developing Adobe AIR for multiple devices and mobile (Desktop, Android, iPhone, iPad), most definetely you will need to define splash screen for specific DPI.
It is pretty simple in Flex all you have to do is create your own preloader and override initialize method.
For mobile there is special class SplashScreen->Sprite which implements IPreloaderDisplay.The most convinent way is to extend this class.
package preloader
{
import mx.core.DPIClassification;
import spark.preloaders.SplashScreen;
import mx.managers.SystemManager;
import mx.utils.DensityUtil;
public class DPIAwarePreloader extends SplashScreen
{
[Embed(source="/../asset/160dpi/splashScreen.png")]
private var splashScreen160dpi : Class;
[Embed(source="/../asset/240dpi/splashScreen.png")]
private var splashScreen240dpi : Class;
[Embed(source="/../asset/320dpi/splashScreen.png")]
private var splashScreen320dpi : Class;
public function DPIAwarePreloader()
{
super();
}
override public function initialize() : void
{
var runtimeDPI : Number = DensityUtil.getRuntimeDPI();
var sysManager : SystemManager =
this.parent.loaderInfo.content as SystemManager;
var splashImage : Class;
switch(runtimeDPI)
{
case DPIClassification.DPI_160:
splashImage = splashScreen160dpi;
break;
case DPIClassification.DPI_240:
splashImage = splashScreen240dpi;
break;
case DPIClassification.DPI_320:
splashImage = splashScreen320dpi;
break;
}
sysManager.info()["splashScreenImage"] = splashImage;
super.initialize();
}
}
}
This will check for runtimeDPI property of your device and set the splash screen designed for specific DPI.
The last step is to add your preloader to the root Application by setting the preloader property in the mxml.
Tags: air, android, desktop, flex, iphone