User Guide

116 Chapter 6: Components Dictionary
3.
In the Actions panel, enter the following code on Frame 1 of the Timeline to define an event
handler for the
click event:
import mx.controls.Alert;
myClickHandler = function (evt){
if (evt.detail == Alert.OK){
trace("start stock app");
// startStockApplication();
}
}
Alert.show("Launch Stock Application?", "Stock Price Alert", Alert.OK |
Alert.CANCEL, this, myClickHandler, "stockIcon", Alert.OK);
This code creates an Alert window with OK and Cancel buttons. When the user clicks either
button, Flash calls the
myClickHandler function. But when the user clicks the OK button,
Flash calls the
startStockApplication() function.
Note: The Alert.show() method includes an optional parameter that displays an icon in the Alert
window (in this example, an icon with the linkage identifier “stockIcon”). To include this icon in your
test example, create a symbol named stockIcon and set it to Export for ActionScript in the Linkage
Properties dialog box or the Create New Symbol dialog box.
4.
Select Control > Test Movie.
Customizing the Alert component (Flash Professional only)
The Alert component positions itself in the center of the component that was passed as its
parent
parameter. The parent must be a UIComponent object. If it is a movie clip, you can register the
clip as mx.core.View so that it inherits from UIComponent.
The Alert window automatically stretches horizontally to fit the message text or any buttons that
are displayed. If you want to display large amounts of text, include line breaks in the text.
The Alert component does not respond to the
setSize() method.
Using styles with the Alert component
You can set style properties to change the appearance of an Alert component. If the name of a
style property ends in “Color”, it is a color style property and behaves differently than noncolor
style properties. For more information, see “Using styles to customize component color and text
on page 67.
An Alert component supports the following styles:
Style Theme Description
themeColor
Halo The base color scheme of a component. Possible values are
"haloGreen", "haloBlue", and "haloOrange". The default value
is
"haloGreen".
backgroundColor
Both The background color. The default color is white for the Halo
theme and 0xEFEBEF (light gray) for the Sample theme.