Avg. Rating 3.7

Problem

Most of you are probably using nativeWindow for creating new windows with ActionScript and wonder why their Flex Components won't get displayed at all by adding them at the DisplayList. Well, as this isn't really well documentated in my mind i'll provide a short resolution/example here.

Solution

To use Flex Components in a new window, you'd have to create a new (mx:)Window instance rather then creating a (mx:)nativeWindow instance. Also you'd need to add the Flex Component to the Window Object directly and not to it's DisplayList. There is a little difference in both of them so i'll provide a little example including comments below.

Detailed explanation

Example with further Explanation:
import mx.core.Window;


//At first you'd need to create a new (mx:)Window instance.
OSWindow = new Window(); 


//You won't need to use a new object for the options like you do in nativeWindow    
//instead you can set the propertys directly.           
//(Hint: showFlexChrome can be disabled in css.)
OSWindow.transparent   = true;
OSWindow.systemChrome  = "none"


//Create a new Panel
var testPanel = new Panel();


//Append that Panel to our Window directly - NOT to the DisplayList (stage)
//Wrong: OSWindow.stage.addChild(testPanel)
OSWindow.addChild(testPanel)


//And last but not least you must use the open method to load the window - activate won't do it here.
OSWindow.open(true);


I hope it's of a little bit of use to you. I'm open to recieve feedback/critique.

Report abuse

Related recipes