views:

422

answers:

4

In our Flex AIR app, we have the problem that our main app window is fairly narrow. This means Alert dialog boxes are chopped on both side, while the right click menu is cropped. How can we get these windows to not get cropped by our main window?

A: 

With flex applications running inside of the flash player, windows cannot be shown outside of the stage. So the only way to make this work would be to make your app larger.

You could though use the flex/ajax bridge and call a javascript alert box instead, they would not be bound by the stage. But it would not be skinned like the rest of the application though and would take some more work to get hooked in, especially if you are listening for the user to click the okay button...

Ryan Guill
Hieronymus
I'm sorry, you said that I and I just read right over it. I am afraid I don't know the answer to that over the top of my head. Could you provide a screenshot of what is happening?
Ryan Guill
+1  A: 

How are you showing the Alerts? If you are using Alert.show(), it will use the default width. However, you can get around this by creating an Alert Object, setting the width manually (or even dynamically), and then using the PopUpManager to show it, place it where you want, and hide it. It takes a little more code, but gives you a lot more flexibility.

Here's a small sample:

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" 
    creationComplete="creationCompleteHandler();">
    <mx:Script>
        <![CDATA[
            import mx.controls.Alert;
            import mx.managers.PopUpManager;

            private function creationCompleteHandler():void
            {
                var alert:Alert = new Alert();

                alert.width = 100;

                alert.text = "this Alert is\n100px wide";

                PopUpManager.addPopUp(alert, this);

                PopUpManager.centerPopUp(alert);

                Alert.show("this Alert uses the default width");
            }
        ]]>
    </mx:Script>
</mx:WindowedApplication>
Eric Belair
+1  A: 

Turn your main AIR window into an invisible transparent window and make your app's primary working window a child of the invisible one. Then when you AIR app starts, make the invisible window the size that encompasses the desktop. You'll then be able to position as many windows and dialogs as you want on this desktop area without worrying about them getting clipped as is happening to you now.

If you want to support multiple screen displays - such that your visible app window can be drug around from display to display, then make your invisible window the size of the entire graphics coordinate system such that it encompasses any and all display screens.

Once you go with the invisible window approach, you'll be able to achieve windowing behaviors that are like that of native applications.

RogerV
A: 

I believe the dojo extensions for adobe air should be able to do what you are after. Never used it myself and not sure what the trade off will be but it might be worth looking at.

http://sitepen.com/labs/dair/

James Hay