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
self-measuring.

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="http://ns.adobe.com/mxml/2009"; 
                                   xmlns:s="library://ns.adobe.com/flex/spark" 
                                   xmlns:mx="library://ns.adobe.com/flex/mx" 
                                   creationPolicy="all" 
creationComplete="init(event)" visible="false">
        
        <fx:Script>
                <![CDATA[                       
                                                
                        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: http://apache-flex-users.2333346.n4.nabble.com/

Reply via email to