Flex 4: Window's minimum size is too big - apache-flex

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>

Related

How to reference the image used as icon for a button in Adobe Flex?

I am developing a Flex application in which I would like to simulate roughly what we get when we serach Google for images. When we pass the mouse pointer over an image, it enlarges a little bit so we can see it better and click it if we want.
I know I could just use an image and increase its size via mouseOver/ mouseOut events, but the thing is that it is much easier for users to realise that they're clickable when I use a button with an icon (as opposed to a plain image).
So here's the question. Is there any way to alter (in this case, its height and width) the button icon through the button methods/ properties?
I can explain it a little further if this is too confusing.
Thank is advance.
P.S.: The way I'm doing it now is by changing the src property of the icon to switch to another (larger) version of the same picture (that requires two versions of each pictures to be stored). However, I'm using the setStyle method to achieve that, which, according to the documentation itself, is not very good performance-wise. And it's so much easier to adjust the size than to have to load another picture which is just an old version of the previous one.
If your picture is enlarged only 'a little bit', you can get away with one (larger) version (just set smoothing = true on underlying Bitmap.) This also enables smooth transition from small to larger version. And hand cursor would be fine way to indicate clickableness, while very large buttons will look strange.
The question was already asked in these threads
Create a button with an icon in actionscript
Set the icon of a Flex button with a Sprite in runtime
According to them there is no graceful solution, but the task can be done via setStyle() or using this snippet:
http://blog.benstucki.net/?p=42
The another way is to use a hack like this (Transparent button over image):
<s:Group width="100" height="20">
<mx:Image source="picture_you_need.jpg" width="100%" height="100%" scaleContent="true" maintainAspectRatio="false"/>
<s:Button id = "test_button" width="100%" height="100%" alpha="0.0"}"/>
</s:Group>

Flex Video Player fullscreenButton override

I'm using mxml to create a spark video player with controls. When I click on the "fullscreen" button in Chrome, it goes full screen on the browser but I am unable to go back to normal size. In Internet Explorer, the whole screen is filled up but the zoom on the video is too big and thus my controls are no longer visible.
Is there any way that I can use ActionScript to control the size of the fullscreen? How would convert the mxml to Actionscript to override this?
Thanks!
Source code from: Flex Video Player
The code I'm using to create the player:
<?xml version="1.0" encoding="utf-8"?>
<s:Application
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark">
<s:VideoPlayer
source="video.flv"
horizontalCenter="0"
verticalCenter="0"
autoPlay="false" />
</s:Application>
You can try to constrain the area for fullscreen display using stage's fullScreenSourceRect property.

air: maximising window on startup

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.

The height and width properties on my Flex 4 app are not working?

In the opening application tag of my Flex 4 app, I set the width and height properties as follows:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="init()"
backgroundColor.mainState="0x303030"
xmlns:components="components.*"
width="798"
height="240">
What I go into Design mode in Flash Builder 4, the app is the correct size. But when I embed the .swf file into a HTML page, the application's background color covers the whole screen, and when the Flash Player Settings message box pops up it is outside of the area I defined in the code above. What am I doing wrong? Thanks for reading.
Set the Flex Application width and height to 100%.
No matter what, the html template's width and height are always 100%,
you have to set the flex application width and height to 100%. Flex
Application itself cannot render on the browser. It needs some kind
of wrapper to render it on the browser. Hence Flex Application gets
wrapped inside an HTML template and the Browser eventually renders
the Flex Application.
Flex Application --> HTML Template --> Browser
Check the index.template.html in the html-template folder. That's the file that generates your index.html when you build; perhaps you could address your problems in there.

How to make a window show up outside the app?

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/

Resources