User Guide

1468 Window component
3. Open the Actions panel, and enter the following click handler in Frame 1:
/**
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.
Customizing the Window component
You can transform a Window component horizontally and vertically while authoring and at
runtime. While authoring, select the component on the Stage and use the Free Transform tool
or any of the Modify > Transform commands. At runtime, use
UIObject.setSize().
Resizing the window does not change the size of the close button or title caption. The title
caption is aligned to the left and the close bar to the right.