Flex and AIR: Open and Close Window Without Re-creating
I would like to open and close a window in Flex(AIR). I would really like to do something like:
var myWindow:Window = new Window();
myWindow.open(true); // open after creating(this works)
myWindow.close(); // now hide the window
myWindow.open(true);// reappear(this doesn't work after a close)
I'm probably missing something simple, perhaps close()
is not what should be used.
The main thi开发者_如何学Gong is I want to create a window once, and then show and hide it as necessary.
EDIT: removed unnecessary vars
May be it's a copy paste error, but var
is required only in the first line. Instead of closing the window, set its visible
property to false
to hide it.
//to hide the window
myWindow.visible = false;
//to show it again
myWindow.visible = true;
Why var at the beginning of every line?
try
myWindow.close();
myWindow.activate();
myWindow.open();
or
myWindow.close();
myWindow = new Window();
myWindow.open();
精彩评论