[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multi-dpi Autoscaling dimensions (android)

leokan23, I don't know if this will help you, but I will tell you my process
for laying things out.  I do not place and widths, heights, positions, or
paddings in my MXML.  When you use percentages for these settings, AIR has
to do a lot of self-measuring, calculating, and then laying out components
and this can be expensive on mobile devices, especially all of the

It is a little more laborious, but I lay everything out manually, but for my
rather large app, it has helped performance a lot.  So in the main app in
the Application tag, I listen for the applicationComplete event. When it
fires, I get the width and height of the device I am on using the following.

AppVars.appWidth = stage.stageWidth;
AppVars.appHeight = stage.stageHeight;

AppVars is just a dummy class that I made to hold a bunch of values that can
be shared across all of my components so I just have to measure the
dimensions one time when the app boots up.  After that, in each component
that I create, I listen for the creationComplete event and set all my
widths, heights, positions and paddings manually like this:

<s:BorderContainer xmlns:fx=""; 
				   creationPolicy="all" creationComplete="init(event)" visible="false">
			import classes.AppVars;
			protected function init(event:FlexEvent):void
				button1.width = AppVars.appWidth * .1;
				button1.height = AppVars.appHeight * .025;
				button1.x = AppVars.appWidth * .25;
                                button1.y = AppVars.appHeight * .25;

This way, the app always looks the same on every device, scales nicely, and
I can count on how it will lay out.  And it does not require all of the
auto-measuring that happens with every component when you lay it out with
percentages.  When i started, this was recommended to me in the past by a
lot of users here and at adobe, and it has worked well for me.

Hope this helps.

Sent from:

( ! ) Warning: include(msgfooter.php): failed to open stream: No such file or directory in /var/www/git/apache-flex-development/msg02627.html on line 121
Call Stack
10.0007364472{main}( ).../msg02627.html:0

( ! ) Warning: include(): Failed opening 'msgfooter.php' for inclusion (include_path='.:/var/www/git') in /var/www/git/apache-flex-development/msg02627.html on line 121
Call Stack
10.0007364472{main}( ).../msg02627.html:0