Apache flex 弹性和空气:打开和关闭窗口,无需重新创建

Apache flex 弹性和空气:打开和关闭窗口,无需重新创建,apache-flex,air,Apache Flex,Air,我想在Flex(AIR)中打开和关闭一扇窗户。我真的想做一些事情,比如: 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) 我可能遗漏了一些简单的东

我想在Flex(AIR)中打开和关闭一扇窗户。我真的想做一些事情,比如:

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)
我可能遗漏了一些简单的东西,也许
close()
不是应该使用的

主要是我想创建一个窗口,然后根据需要显示和隐藏它


编辑:删除不必要的变量

为什么在每行开头都有变量

试一试


可能是复制粘贴错误,但仅在第一行中需要
var
。不要关闭窗口,而是将其
visible
属性设置为
false
以隐藏窗口

//to hide the window
myWindow.visible = false;

//to show it again
myWindow.visible = true;
myWindow.close(); 
myWindow = new Window();
myWindow.open();
//to hide the window
myWindow.visible = false;

//to show it again
myWindow.visible = true;