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
when the user clicks the button my_button. The click event handler,
buttonListener.click()
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
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.
1468
Window component
function that the
click()
, calls
PopUpManager.createPopUp()
event listener calls
buttonListener
to instantiate a window
UIObject.setSize()
.
Need help?
Do you have a question about the FLASH 8-COMPONENTS LANGUAGE and is the answer not in the manual?
Questions and answers