O'Reilly logo

Programming Flex 2 by Joey Lott, Chafic Kazoun

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

There are two basic sorts of pop ups you can use 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 that you can use to manipulate the Alert instance if needed. Example 8-2 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required