Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I check what kind of device the user is running my Adobe AIR app on?

Example: if(device == ipad3) { stagestuff.width = 300; }

share|improve this question

At this link, it shows the following:

'Hi all,

I am sharing some of my library of iOS specific stuff in the hope that the community can suggest improvements and that it may be useful to others.

The following code can determine iPhone, iPodTouch and iPad based on screen res and geolocation (iTouch has no GPS). If anybody can help with code that can narrow the selection (i.e. determine between 3G, 3GS, 2nd gen, 3rd gen etc) that would be most welcome!

edit: hmm. Just realised that the iPhone 1st gen also didn't have GPS, so i can't use that to distinguish iTouch from iPhone...

package com.pixelthis.frameworks.ios



      * ...

      * @author Peter Vullings


     public class DeviceType


          import flash.system.Capabilities;

          import flash.sensors.Geolocation;

          // ------------------------------------------------------

          // CONSTANTS

          // ------------------------------------------------------

          public static const IPHONE : int = 1;

          //public static const IPHONE_3G : int = 2;

          //public static const IPHONE_3GS : int = 3;

          public static const IPHONE_4 : int = 4;

          public static const IPODTOUCH : int = 100;

          //public static const IPODTOUCH_2GEN : int = 101;

          //public static const IPODTOUCH_3GEN : int = 102;

          public static const IPAD : int = 200;

          // ------------------------------------------------------

          // PROPERTIES

          // ------------------------------------------------------

          public static var _currentDevice : int = 0;

          // ------------------------------------------------------

          // METHODS

          // ------------------------------------------------------


           * Determine the current device type

           * @return The device type


          public static function get currentDevice():int {

               // If we have already calculated it, return it. The device

               // isn't exactly going to change at run-time is it!

               if (_currentDevice>0) return _currentDevice;

               // Screen size

               var w : int = Math.max( Capabilities.screenResolutionX, Capabilities.screenResolutionY );

               var h : int = Math.min( Capabilities.screenResolutionX, Capabilities.screenResolutionY );

               if (w <= 480){

                    if (Geolocation.isSupported){

                         _currentDevice = IPHONE;


                         _currentDevice = IPODTOUCH;


               }else if (w<=960){

                    _currentDevice = IPHONE_4;


                    _currentDevice = IPAD;


               return _currentDevice;



share|improve this answer
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post. – Anko Mar 6 '13 at 10:20
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – bummzack Mar 6 '13 at 10:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.