I am developing an application for desktop and mobile devices and would like to use the same code base for each assembly.
I want to use cacheAsBitmapMatrixfor some of my display objects, but it cacheAsBitmapMatrixthrows an error if it is included in an AIR application with a device profile other than mobileDevice or extendedMobileDevice.
something like the following would be ideal:
if (cacheAsBitmapMatrix.isSupported)
myDisplayObject.cacheAsBitmapMatrix = new Matrix();
using try / catch:
try {myDisplayObject.cacheAsBitmapMatrix = new Matrix();}
catch(error:Error) {}
finally {myDisplayObject.cacheAsBitmap = true;}
update:
with the exception of television profiles, this should also work to distinguish between mobile and desktop:
if (Capabilities.os.indexOf("Windows") > -1 || Capabilities.os.indexOf("Mac") > -1 || Capabilities.os.indexOf("Linux") > -1)
trace("Desktop Profile");
else
trace("Mobile Profile");
update 2:
seems like the easiest way, and perhaps the most common way to determine the profile at runtime is to call:
NativeWindow.isSupported;
flash.display.NativeWindow :
AIR: , AIR . , NativeWindow.isSupported. AIR API .
3:
BlackBerry PlayBook NativeWindow. , , . , :
if (
(Capabilities.os.toLowerCase().indexOf("mac") == -1) &&
(Capabilities.os.toLowerCase().indexOf("windows") == -1) &&
(Capabilities.os.toLowerCase().indexOf("linux") == -1)
)
deviceIsMobile = true;