| Previous | |
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
| Questions or Feedback? | Previous | |
- AS2 Migration
- Getting Started - Flash
- Debugging in Flash
- Building your application from inside Flash
- Getting Started - Flex
- Debugging in Flex
- Using mProjector - Compile Your SWF into an Appli
- Customizing The About Window
- Debugging Your Application
- Launching Application at Startup
- Mac vs. Windows Application Development
- Menus
- Dynamic Window Creation
- Application Basics
- mProjector Class Basics
- Add Remove Programs Control Panel
- Fullscreen and Center
- Check Connection and Download File
- Choose Files
- Creating an Installer
- Creating and Controlling Multiple Windows
- Cut, Copy, and Paste (Windows)
- Desktop Shortcut and Start Menu Support
- Drag and Drop Files
- Embedding HTML and other Media types
- Flash-Shaped Windows
- Message Box
- Open Documents
- Project Files
- Reading and Writing to Hard Drive
- Startup Application
- Wallpaper and Screensaver
- Window to Window Communications
- Working with Included Files
- Context Sensitive Menus
- Alert User
- Screen Resolution
