Displaying a yes/no dialog box in Flash using JSFL

by Peter deHaan on November 28, 2008

in JSFL

In a previous example, “Displaying messages in Flash using JSFL”, we saw how to display a simple text message to a user using JSFL and the alert() method.

The following example shows how you can display a simple yes/no dialog box (or more accurately an OK/Cancel dialog box) using the confirm() method.

Full code after the jump.

// JSFL
confirm("Are you sure you want to delete the Internet?");

The previous example displays a simple OK/Cancel dialog box, but ideally you’d want to capture the user’s response and use it in your JSFL code. The following example shows how you can ask the user whether they want to save any open/modified Flash documents before closing them:

// JSFL
var result = confirm("Do you want to save any files or whatever?");
fl.closeAll(result);

If the user clicks the “OK” button, the result variable will contain a value of true. Conversely, if the user clicked the Cancel button, the result variable will contain a value of false.

{ 0 comments… add one now }

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Previous post: Displaying messages in Flash using JSFL

Next post: Prompting the user for information in Flash using JSFL