Multiple Windows

Creating Child Windows

mProjector enables you to create more than one projector window, each playing a different SWF file. The windows can call each other’s mWindow commands, so you can resize, reposition, minimize, restore, etc. parent and child windows using ActionScript.

For example, the main window creates a child window and positions it in the upper left of the screen using the following code:

var childWindow = mApplication.createWindow("child.swf",100,100,"","Test","WINDOWLESS");
if (childWindow) {
    childWindow.setPostion(0,0);
}

 

Window to Window Synchronous Communication

Additionally, windows can communicate with each other via custom-defined synchronous functions. A function defined as a member of a child window’s mWindow object can be called by the window that created it, provided this window keeps a reference to the child window.

For example, the main window creates a child window using the following function:

var childWindow = mApplication.createWindow("child.swf",100,100,"","Test","WINDOWLESS");

It can then call a function defined in the child window:

childWindow.doSomething("hello");

This function must be defined in the child window’s ActionScript 3.0 and registered as an mWindow callback function as follows:

function doSomething (s:String)
{
mWindow.setTitle(s);
}
mWindow.addCallback("doSomething", doSomething);

ActionScript 2.0 window to window communication is a bit different. In AS2 the function must be defined in the child window as an mWindow method. No callback registration is necessary.

mWindow.doSomething = function (s:String)
{
mWindow.setTitle(s);
}

Similarly, a child window can call any of the functions created as members of the main window’s mWindow object. For example, the child window can call the main window’s "multiply" function:

var parentWindow = mApplication.getWindow();
var result = parentWindow.multiply(3,5);

This function must be implemented in the main window’s ActionScript 3.0 code as:

function multiply (a, b){return a*b;}
mWindow.addCallback("multiple", multiply);

or in ActionScript 2.0 as:

mWindow.multiply = function (a, b){return a*b;}

You can download a couple sample applications demonstrating dynamic windows from the mProjector Samples page -- /software/flash-projector/flas.html