Pop Ups
The Flex framework has built-in support for pop-up windows and alerts. Pop ups can be useful for many reasons, including notifying the user of messages or news and displaying simple forms such as login forms or mailing-list sign-up forms. Unlike HTML pop ups, Flex pop ups do not open new browser windows. Flex application pop ups appear within the same Flash Player instance. This means that Flex application pop ups are never subject to the same restrictions as some types of HTML pop ups.
You can use two basic types of pop ups in Flex applications: alerts
and custom pop-up windows. Alerts are quite similar to the pop ups that
appear in HTML applications when using the JavaScript alert()
function. They display text messages to
the user in a modal window, and prompt the user to click a button.
However, as we’ll see in the next section, Flex alerts are more
sophisticated than HTML alerts. Custom pop ups allow you to create more
complex pop-up content. For example, using a custom pop up you can display
a mailing list email form.
Using Alerts
Flex alerts are instances of the mx.controls.Alert
component. Unlike many of the other Flex components, you cannot
create an alert using MXML tags. You must use the static show()
method of the Alert
class. The show()
method requires at least one parameter:
a string specifying the message to display. The show()
method returns a reference to the new
Alert
instance, which you can use to
manipulate the Alert
instance if
needed. Example 10-2 displays ...
Get Programming Flex 3 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.