User Guide
66 Alert component (Flash Professional only)
Using the Alert component (Flash
Professional only)
You can use an Alert component whenever you want to announce something to a user. For
example, you could display an alert when a user doesn’t fill out a form properly, when a stock
hits a certain price, or when a user quits an application without saving the session.
Alert parameters
The Alert component has no authoring parameters. You must call the ActionScript
Alert.show() method to display an Alert window. You can use other ActionScript properties
to modify the Alert window in an application. For more information, see “Alert class (Flash
Professional only)” on page 71.
Creating an application with the Alert component
The following procedure explains how to add an Alert component to an application while
authoring. In this example, the Alert component appears when a stock hits a certain price.
To create an application with the Alert component:
1. Drag the Alert component from the Components panel to the current document’s library.
This adds the component to the library, but doesn’t make it visible in the application.
2. In the Actions panel, enter the following code in Frame 1 of the to define an event handler
for the
click event:
import mx.controls.Alert;
// Define action after alert confirmation.
var myClickHandler:Function = function (evt_obj:Object) {
if (evt_obj.detail == Alert.OK) {
trace("start stock app");
}
};
// Show alert dialog box.
Alert.show("Launch Stock Application?", "Stock Price Alert", Alert.OK |
Alert.CANCEL, this, myClickHandler, "stockIcon", Alert.OK);