I am trying to make a function that opens a window but makes sure the same window is not already open. I want to be able to pass it a non-instantiated var or an instantiated var and it work either way. If the window is already open it closes it then reopens it.
So I need a way to pass a variable of type Window or a subclass if it, and instantiate the proper subclass.
I am looking for something like this:
public function openWindowOnce(window:Window):void
{
if(isOpen(window))
{
closeIfOpen(window);
}
window = new Window(); /**<-- THIS LINE window can also be a sublcass of window,
* I want to instatiate the correct sublass,
* I also want to make sure that it is a Window or a
* Sublcass of window before I instatiate it.
*/
window.open();
}
Thanks!