Home > Articles

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

Getting a Window Reference

Before you can work with a particular window, you first need to get a reference of that Window instance. The following sections describe the various ways to obtain a Window reference.

Window Constructor

You can use the window constructor for a new NativeWindow to get a reference, like this:

var myWindow:NativeWindow = new NativeWindow();

Current Window Stage

You can get a reference directly from the current window stage, as follows:


Display Object on the Stage

Any display object on the stage can also give you a reference, as follows:


As an example, suppose you have an mx.containers.Panel in some window. To get the reference to the parent NativeWindow instance, you can do this:


Referencing the Active Window

A desktop window that currently holds user focus is referred to as the “active” window. You can reference this window via NativeApplication, as follows:

var myWindow:NativeWindow = NativeApplication.nativeApplication.activeWindow;

Referencing All Opened Windows

All open windows can be referenced via the nativeApplication object. These can be cycled through like any Array. Each element will be a NativeWindow instance.

var myWindows:Array = NativeApplication.nativeApplication.openedWindows;
  • + Share This
  • 🔖 Save To Your Account