| Previous | Next |
mWindow.addCallback()
Availability
| Support | PC | Mac | Package (AS3) / Scope (AS2) |
|---|---|---|---|
| ActionScript 3.0 | 4.0 | 4.0 | stm.mprojector.mWindow stm.mprojector.mWindowCallback |
| ActionScript 2.0 |
Usage
mWindow.addCallback(type:String, callbackFunction:Function) : VoidParameters
type - xref=mWindowCallback.CLOSE (for versions >= 4.0.20 PC) OR name of method callable from another mProjector window.
callbackFunction
Returns
Nothing.
Description
Method; Register a function as callable by another mProejctor window from the same application OR as the mWindowCallback.CLOSE callback function. This function in not used for window to window communication in AS2. In AS2, just add the callable function to the mWindow class.
ActionScript 3.0 Example:
In this example the child defines a method, messageReceiver, to receive messages from the parent window. To make the function callable from other windows it must be associated with the windows mWindow class. In AS3 this method must be registered as an mWindow callback function using mWindow.addCallback(). In AS2 the function needs to be added to the mWindow class.
// ActionScript in child.swf
import stm.mprojector.mWindow;
// define function
function messageReceiver (message: String):void {
message.text = message;
};
// register messageReceiver as callable by other windows.
mWindow.addCallback("messageReceiver", messageReceiver);
// ActionScript in parent.swf
childWindow = mApplication.createWindow( "child.swf ", 50, 50, "CHILD ", "CHILD ", "STANDARD ",
160000, true, 100, true, true, " ");
if (childWindow != null) {
mApplication.trace( "childWindow: " + childWindow.toString());
childWindow.messageReceiver( "hello from parent ");
}
};ActionScript 2.0 Example:
In this example the child defines a method, messageReceiver, to receive messages from the parent window. To make the function callable from other windows it must be associated with the windows mWindow class. In AS3 this method must be registered as an mWindow callback function using mWindow.addCallback(). In AS2 the function needs to be added to the mWindow class.
// ActionScript in child.swf
mWindow.messageReceiver = function (message: String):void {
message.text = message;
};
// ActionScript in parent.swf
childWindow = mApplication.createWindow( "child.swf ", 50, 50, "CHILD ", "CHILD ", "STANDARD ",
160000, true, 100, true, true, " ");
if (childWindow != null) {
mApplication.trace( "childWindow: " + childWindow.toString());
childWindow.messageReceiver( "hello from parent ");
}
};
Code Examples
Code Examples
Window to Window Communications
| Questions or Feedback? | Previous | Next |
- 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
