In my air app I am maximizing the app window on creation complete event. Because of this I initially get a smaller window for a few milliseconds which is maximized after all UI elements are rendered. Is there any way I can specify that the initial size of the window should be maximal? Hard coding the size will not works as the screen sizes may change. My current code is:
<s:WindowedApplication .... creationComplete="maximize();">
.
.
.
</mx:WindowedApplication>
Make the initial window not visible (in the app.xml file). Then in an applicationComplete event handler maximize the window and make it visible.
Related
I am developing a JavaFX control, that draws lines between its child components. Those child components grow when there is room. To draw lines between them, I am working a lot with Node.getBoundsInParent(), called whenever the control's size changes.
That all works fine, when I resize the window.
When I maximize the window, the components grow and are layouted as expected. Since the controls size changed, the bounds are read again - but they are still in the state before maximizing the window.
When I stop maximizing the window, the size changes calling getBoundsInParent() returns the maximized sizes of the components.
I tried to explicitly listen to the Window maximizing event and call requestLayout() on my control, but the effect is still the same.
What am I missing?
It seems, it helped that when triggering a redraw, I had to put that redraw in a Platform.runLater() call. That worked for resizing and maximizing as well.
I tell the window to create with a size of 32x32
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
showStatusBar="false"
width="32"
height="32">
but it appears like this
The yellow box is an image that's 32x32.
try setting minWidth=32 minHeight=32
You have something in your window that is more than 32X32 so the window got resized to fit its content, sharing your full code will help us finding the problem.
The AIR application config xml file has a minwidth property. I assume you're on windows. In that case, the close, minimize, fullscreen buttons should always be visible, so you can't make smaller window (try resizing notepad.exe to understand). If you want smaller, you have to make a chromeless application / window (again in the config xml). That will allow you to create 1x1 px windows as well, but you'll have to add your own close button.
<systemChrome>none</systemChrome>
When running air application and clicking the windows resize button (+ on a mac) , how is the new size determined? can that be controlled somehow?
Thanks
You can try listenting to resizing event or displayStateChange event and then set your own sizes.
You can also play with maximizible property of NativeWindow(it can't be changed after window is created, however, you can define it initially).
Basically what is happening is:
Window is closed when Maximized (of type AIRWindow.as which extends Window.as)
When reopened, this window is in Maximized state, and Air has no record of a restore window size at this point.
Click the Restore button - AIRWindow.restore() calls Window.nativeWindow.restore()
AIR resizes the window, but makes it basically the same size or slightly larger than Maximized state
We don't have access to NativeWindow file, or the restore() function, so I'm not sure how to affect the default resizing of the maximized window to a restored state?
Any ideas?
Note: NativeWindow is part of the airglobal.swc package
Are you able to set the initial window size when you create it?
When I create classes derived from NativeWindow I set the x,y,width and height properties prior to calling activate(). This size is then used as the basis for restore operations if you subsequently maximize/minimize.
You could create the window at a specific size and then immediately maximize it on load if you initially want it maximized.
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?
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.
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>
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...
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/