I have a project originally created using Flex 3 where I created several mx.core.Window at runtime (in actionscript).
Last week I updated the Flex sdk to 4.1 and I replaced the use of mx.core.Window for spark.components.Window (as recomended by the documentation). Here's the code I'm using:
private var _win:Window = new Window();
_win.maximizable = false;
_win.minimizable = false;
_win.resizable = false;
_win.showStatusBar = false;
_win.systemChrome = NativeWindowSystemChrome.NONE;
_win.type = NativeWindowType.LIGHTWEIGHT;
_win.width = 800;
_win.height = 600;
_win.transparent = true;
My problem is that the "transparent" property has stopped working! Although i set transparent=true, the window is always opaque. And this worked in mx.core.Window!
I was careful to check that I had systemChrome=none.
I tried setting the opaqueBackground property to null. It didn't work.
I have already tried replacing the window's skin class for one with alpha=0 but that does not work either (although it works if I try to replace the default background color to red (0xFF0000), for example).
Just out of curiosity, I noticed that if I set the alpha property of the window after it was open, it does turn transparent - along with all it's contents!!! By this I mean that everything object inside that window will also be transparent... That is not the behavior I need - I need a window with transparent background with visible opaque objects inside - just as I used to have with mx.core.Window...
Is this a bug of the spark Window? Should I rollbak my code to the old mx Window?
Did you try setting backgroundAlpha = 0 as well as the transparent flag?
Thank you for your reply.
In fact, adding the following line to the code seems to solve the problem
(...) _win.height = 600; _win.setStyle("backgroundAlpha", 0); _win.transparent = true; _win.open(true);
Nevertheless, to me this seems to be just a workaround, not a solution. For 2 reasons:
1) mx.core.Window worked without the workaround
2) I don't see a reason why one should need to set the transparency twice - setting transparent=true should automatically set the backgroundAlpha style of the UIcomponent to 0.
Could someone please explain this to me?