Question

How would I go about finding the display size and position of the stage or navigator area in Adobe Flex mobile? I would like to be able to make something the exact width and height (without using 100% w&h). And position the top at the top of the stage. I'm sure this description isn't the easiest to understand, so hopefully this image will help:

Application Layout

        protected function init(event:FlexEvent):void
        {
            if (NativeMaps.isSupported){
                NativeMaps.service.addEventListener(Event.ACTIVATE, mapReady2);
                //NativeMaps.service.addEventListener(NativeMapEvent.MAP_CREATED, mapReady);                    
                try{
                    NativeMaps.service.mapOptions.compassEnabled=true;
                    NativeMaps.service.mapOptions.zoomControlsEnabled = true;
                    NativeMaps.service.mapOptions.zoomGesturesEnabled = true;
                    NativeMaps.service.mapOptions.rotateGesturesEnabled = true;
                    NativeMaps.service.mapOptions.myLocationButtonEnabled = true;
                }catch(e:Error){
                }
                var tla:ViewNavigatorApplication=FlexGlobals.topLevelApplication as ViewNavigatorApplication;                   
                var width:Number = tla.width;
                var height:Number = tla.height-tla.actionBar.height;
                var x:Number = 0;
                var y:Number = tla.actionBar.height;

                NativeMaps.service.createMap(width,height,x,y);
            }
        }
Was it helpful?

Solution

I think this is what you need:

var tla :ViewNavigatorApplication = FlexGlobals.topLevelApplication as ViewNavigatorApplication;
var width :Number = tla.width;
var height :Number = tla.height=tla.actionBar.height;
var x :Number = 0;
var y :Number = tla.actionBar.height;

Then size your component using the width and height and position it using the x and y values. I wrote this in the browser, so expect typos in code. There may be some padding issues that make the sizes / positioning slightly off but you'll have to try it and see what you get.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top