Skip to main content
Participant
January 19, 2012
Question

Creating an app for different screen resolutions/sizes

  • January 19, 2012
  • 3 replies
  • 1936 views

Hi

I'm currently in the process of learning application development for the iPhone and could do with some help on how to cater for retina and non-retina screens. I want to create image assets for each screen type.

What the best way to go about detecting if the user has an iPhone 4 for example and selecting the appropriate images for that resolution? I understand that you attach '2x' to file names when coding natively but for a pure Actionscript project where the assets might be contained in a swc file what would be best to do?

Thanks

This topic has been closed for replies.

3 replies

January 20, 2012

Hi,

So far I've only been developing for iOS devices using Flash CS5.5 and publishing to AIR for IOS.

To date I've only been developing for the lowest res - which I believe is the iPod Touch 3G / iPhone 3G - a res of 320 x 480 px.

I've seen one of the apps I produced this way running on an iPod Touch 3G, iPad1, and an iPhone 4.

Considering this is the lowest res, the results aren't bad.  The iPad gives you the option to run it at it's native size, or to scale it up (which basically applies some sort of zoom).  Obviously, when scaled, some pixelation occurs.

This isn't a perfect solution by far - but it will at least mean that your app should be viewable on every iOS device (that's my theory anyway).

Cheesrs.

January 20, 2012

Hi Vic,

The biggest advantage of building apps in Flash CS5.5 or Flex is the ability to target multiple devices and the 2 major platforms, iOS and Android oh and also Blackberry (anyone?).

Best way to approach a build is to assume you do not know the screen size your app will be used on, since Android is so all over the place.

I have been using stage.stageHeight and stage.stageWidth religiously for all my scaling although I have heard that method has its problems, it has worked well for me, I have put out 2 apps personally and 3-4 for work using this method both in Landscape and Portrait orientations and this method has worked well.

The easiest way to build a multi screen app is to design it for an average ratio, 3:4 being the lowest = iPad so lets say you pick some decent size that wont be too big for smaller screens like the iPhone 3gs 480x320 and wont be too low for high res screens like the new Google Nexus or the Motorola Xoom 1280x800. I usually target the iPhone 4 screen 960x640 right now it seems to fall in the middle between older phones and tablets.

The real quick and dirty way of doing it is to build all your assets inside a movie clip and then scale that movie clip proportionally to the stage, first checking to make sure none of it would be cut off due to different screen ratios, this is not the best way of doing it but it works well and its the easiest method.

A better way is to scale and place your content in relation to the stage, again the stage.stageWidth and Height properties are your friends so if you have an element that always goes in the middle you would place it my_mc.x = stage.stageHeight / 2 and same with the y, you can also scale it to the stage my_mc.width = stage.stageWidth/4 this way the movie clip is always 1/4th of the stage width regardless of the screen, its a lot planning up front but this method allows you to cover the entire screen instead of just cramming your movie clip in there however it fits.

Let me know if any of that helped I can go into further detail but I feel like I am rambling on.

vicd0111Author
Participant
January 20, 2012

Hi Mark

That's great thanks. You are not rambling - the more information I can get the better!

In terms of the screen width should I use screenResolutionX/Y? I'm using Flash Builder 4 and using metadata to set the width and height of the swf to 640x960. When the app is run on a device does it run full screen with the dimensions being adjusted?

January 20, 2012

Vic,

I tend to start the first frame of all my mobile projects with this bit of code

stage.scaleMode = StageScaleMode.NO_SCALE;

stage.align = StageAlign.TOP_LEFT;

stage.quality = StageQuality.LOW;

This forces all your coordinates to zero out in the top left side of the screen and remove auto scaling, try this with your current code to see if it makes a difference.

The LOW stage quality works well if you use all bitmaps and gpu rendering, it greatly helps performance.

January 19, 2012

Are you considering Flex Application or pure AS application?

vicd0111Author
Participant
January 19, 2012

Pure AS application.

January 19, 2012

Hi :

Using Capabilities.screenDPI will help you decide the kind of images to pick-up. Then you can use any startegy like suffixing or having same file name but within different directory each representing different DPIs you want to address.

Does that help?