Tuesday, January 29, 2008

Is your PopupButton suffering from Alzheimer?

Recently I noticed that my PopupButton didn't want to popup anymore... Sometimes it worked and most of the time it didn't. The problem is related to a 'fix' Adobe did to get rid of a memory leak. The 'fix' may have fixed the memory leak but introduced serious trouble. Scott Melby seems to have found a workaround that works most of the time. More information on http://tech.groups.yahoo.com/group/flexcoders/message/99105. Let's hope this gets fixed soon because it's clearly a bad fix.

Thursday, January 24, 2008

How to use a percentage for maxWidth or maxHeight?

Recently I wanted to set the maxHeight of a component to a percentage. Sadly enough this isn't supported in Flex. There's however a very simple workaround that seems to work all the time: set the maxHeight or maxWidth in the resize event of its container:

<mx:Canvas
  id="cnvsComponent"
  resize="childComponent.maxHeight = cnvsComponent.height"
  width="100%" height="100%">
    <mx:Tree id="childComponent" />
</mx:Canvas>

Tuesday, January 22, 2008

Taming your combobox width

Recently I discovered that setting a combobox to width="100%" doesn't mean the combobox won't grow bigger than the width of its container. If the text cannot be completely displayed your combobox becomes wider than 100%. You can use the following construction to tame its width:

<mx:canvas id="cnvs" width="100%" resize="cb.width = cnvs.width">
  <mx:combobox id="cb" text="this is a rather long combobox text" />
</mx:canvas>

Simply add a canvas around the combobox and explicitly set the width of the combobox to the width of the canvas through the resize event of the canvas. This solution works because the problematic behaviour only occurs when using a percentage width.


The same applies to the Label component (and probably some other components as well).

Friday, January 18, 2008

Trouble centering your popups ???

I had some trouble centering popups created through PopupManager. If you simply use 'this' as the parent display object then the popup is 'centered' according to the parent component specified (instead of to the complete stage). If you want to center your popup in the middle of your application screen you should specify 'Application.application.parentDocument'...