ActionScript 2.0 Components Language Reference |
|
|
|
| Window component > Using the Window component > Creating an application with the Window component | |||
The following procedure explains how to add a Window component to an application. In this example, when the user clicks a button the window displays an image.
To create an application with the Window component:
/**
Requires:
- Button component on Stage (instance name: my_button)
- Window component in library
*/
import mx.containers.Window;
var my_button:mx.controls.Button;
System.security.allowDomain("http://www.helpexamples.com");
// Create listener object.
var buttonListener:Object = new Object();
buttonListener.click = function(evt_obj:Object) {
// Instantiate Window.
var my_win:MovieClip = mx.managers.PopUpManager.createPopUp(evt_obj.target, Window, true, {title:"Sample Image", contentPath:"http://www.helpexamples.com/flash/images/image1.jpg"});
my_win.setSize(320, 240);
};
// Add listener.
my_button.addEventListener("click", buttonListener);
This example creates a click() function that the buttonListener event listener calls when the user clicks the button my_button. The click event handler, buttonListener.click(), calls PopUpManager.createPopUp() to instantiate a window that displays an image. To close the window when the OK or Cancel button is clicked, you would need to write another handler.
|
|
|
|