Skip to main content
jg716
Inspiring
March 13, 2012
Question

Window Creation Question/Issue

  • March 13, 2012
  • 2 replies
  • 658 views

I have an application where I wish to have some secondary utility windows.  For various reasons, I wanted to create these windows during the application initialization, but not "use" them immediately.  To do so, I created a function to create each window and store it in a variable for later use.  Because I don't want to display these windows, I simply didn't call activate() on them during creation.  The goal is to keep the subwindows hidden until needed.  If I activate them, they appear.  If I activate them and set visible to false, they appear and disappear.  I'd like to not have the windows flash on-screen.

At a later point, if the user requests, I open the appropriate subwindow by calling activate().  This is where the problem arose.

It seems that if all the windows don't get activated, when the user clicks the SystemChrome exit button (X), the NativeWindow.nativeApplication's EXITING and CLOSING events don't fire.

What I'm seeing may be a feature and not a bug, but is it possible to create a subwindow without activating it and not disrupt the exiting/closing of the main application.

Thanks!

P.S. - I recognize that one approach is to create these windows as needed.  I was just trying to be a little efficient by creating them ahead of time.

This topic has been closed for replies.

2 replies

jg716
jg716Author
Inspiring
March 16, 2012

Chris,

Thanks for the response.  I managed to work around the problem by creating the window content (Sprite/MovieClip) ahead of time, but creating the sub-windows as needed.  In the process, I figured out that when multiple windows are open, closing the main window doesn't necessarily trigger the Exiting event.  Closing the last open window does.  So I've now setup my application to respond to both the Exiting event and the main window's closing event to do my cleanup and exit.

I'm thinking that the condition described above somehow falls into the same category.  I haven't tested it yet, but I think that the act of creating the sub-windows (even though they are never activated) are counted as "open" and therefore the Exiting event isn't triggered.

I'll post a follow-up once I've tested that theory.

jg716
jg716Author
Inspiring
March 13, 2012

This code shows the issue.  After creating the subwindow, but not activating it, the exit handler will not be called...

package 
{
import flash.events.Event;
import flash.desktop.NativeApplication;
import flash.display.MovieClip;
import flash.display.NativeWindow;
import flash.display.NativeWindowInitOptions;
import flash.display.NativeWindowType;
import flash.display.StageAlign;
import flash.display.StageScaleMode;

public class ExitTest extends MovieClip
{
  private var _subWindow:NativeWindow;
  public function ExitTest()
  {
   createSubWindow();
   NativeApplication.nativeApplication.addEventListener(Event.EXITING, exitHandler);
  }
 
  public function createSubWindow():void
  {
   var initOptions:NativeWindowInitOptions = new NativeWindowInitOptions();
   initOptions.type = NativeWindowType.UTILITY;
  
   _subWindow = new NativeWindow(initOptions);
   _subWindow.height = 400;
   _subWindow.width = 320;

   _subWindow.stage.align = StageAlign.TOP_LEFT;
   _subWindow.stage.scaleMode = StageScaleMode.NO_SCALE;
  }
 
  public function exitHandler(e:Event):void
  {
   trace("Exiting");
  }
}
}

chris.campbell
Legend
March 16, 2012

Hi, I'm not sure off the top of my head if this is possible.  I've run into window confusion myself on Mac so I'm probably not the best person to ask.  Hopefully someone else can chime in.  In the meantime, could you please open a new bug report on this over at bugbase.adobe.com?  Please post back with the URL so that others affected can add their comments and votes.

Thanks