• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

How do I get the DPI and resolution of device?

Guest
Nov 12, 2015 Nov 12, 2015

Copy link to clipboard

Copied

How do I get the DPI and resolution of device?

Is this easily possible yet? I remember this wasn't really possible a few years ago.

TOPICS
Development

Views

1.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 12, 2015 Nov 12, 2015

Copy link to clipboard

Copied

Could be you've been looking for this http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/Capabilities.html#sc... ?

This like is more general on how to develop multi res apps Multiscreen Support in Mobile AIR Applications

Also, Starling/Feathers have helpful util function to do that.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 12, 2015 Nov 12, 2015

Copy link to clipboard

Copied

Thanks for this link:

Multiscreen Support in Mobile AIR Applications

I will try it out and see how it goes.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 19, 2015 Nov 19, 2015

Copy link to clipboard

Copied

I use capabilities.screenDPI in every app, and have done for some while.  It seems to work ok!

Specifically, I use this snippet of code to detect if I'm running on a screen larger than 6", and then I use that to scale down my UI so that it doesn't look enormous on larger screens:

var screenWidth : Number = Math.max( stage.fullScreenWidth, stage.fullScreenHeight );

var screenHeight : Number = Math.min( stage.fullScreenWidth, stage.fullScreenHeight );

var w : Number = screenWidth / Capabilities.screenDPI;

var h : Number = screenHeight / Capabilities.screenDPI;

var screenSizeDiagonal : Number = Math.sqrt( w * w + h * h );

var isTablet : Boolean = screenSizeDiagonal >= TABLET_SCREEN_SIZE; // TABLET_SCREEN_SIZE = 6

Please note that this is just a snippet of the full code I use, and there is actually a whole bunch more that goes on to detect proper screen size and orientation.  This will work in most cases though.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 19, 2015 Nov 19, 2015

Copy link to clipboard

Copied

I'd love to know about your approach of scaling UI depending on the device. Do you apply some kind of ratio to all display objects sizes, positions ? Or only to the top most one?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 19, 2015 Nov 19, 2015

Copy link to clipboard

Copied

LATEST

My general rule of thumb has been to scale everything to 80% of what it would normally be on larger screen devices.  Sometimes you get apps that look like children's apps on iPad because the UI is so large.  80% seems to be about right,  Then I use the same positioning rules as normal to make sure I handle all screen sizes.  i.e. nothing is absolute positioned - everything is based either on a corner or edge of the screen or the center - for example, a score counter might sit relative to the top center.  A menu button is always positioned relative to top left etc, and all positions are scaled based on the screen size.

I make mostly games by the way, but this would apply to other apps too.

I also have code that can change layout based on landscape and portrait, and in some cases a different layout for 3x4 ratio screens (short and fat like an iPad), 3x2 screens (like original iPhone) and 16x9 (like most modern widescreen devices), and also based on language (because some languages, like German or Russia, are typically longer to say the same thing as the English equiv).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines