Home
HomeFlexible, Lightweight and Truly Skinnable Flash ComponentsPHPObject and other Flash ExtensionsForumsBlog JournalLinks
Buy Flash Components
  GhostWire Components - Flash Components for RIAs
redhand GhostWire DialogBox - Usage

Using the DialogBox component
First, drag an instance of the DialogBox from the Components Panel to the Stage. Give this instance a name, example "myDialogBox". You can place this instance anywhere on the Stage. It is recommended that you place it on its own layer and hide that layer:

With this instance on the timeline, you can invoke the AlertBox, ConfirmBox or PromptBox.

---

How do I invoke an AlertBox?
An AlertBox is a dialog box that presents a message to the end user and has one response button 'OK'. To call up an AlertBox, simply use the method
GWDialogBox.alert(message);
Example:
myDialogBox.alert("You have a new message!");

---

How do I invoke a ConfirmBox?
A ConfirmBox is a dialog box that presents a message to the end user, expecting a feedback from the user and has two response buttons which by default are 'OK' and 'Cancel'. To call up a ConfirmBox, simply use the method
GWDialogBox.confirm(message);
Example:
myDialogBox.confirm("Do you wish to logout?");

---

What if I need more than two buttons for the ConfirmBox?
The ConfirmBox can take in an optional second parameter. This parameter should be an array of button labels.
GWDialogBox.confirm(message,buttonLabels);
Example:
myDialogBox.confirm("Save changes to Untitled-1?",["Yes","No","Cancel"]);
The above example calls up a ConfirmBox with the message "Save changes to Untitled-1?" and presents three buttons with the labels "Yes", "No", and "Cancel" respectively.

---

How do I invoke a PromptBox?
A PromptBox is a dialog box that presents a message to the end user, expecting a text input from the user and has two response buttons which by default are 'OK' and 'Cancel'. To call up a PromptBox, simply use the method
GWDialogBox.prompt(message,defaultreply);
Example:
myDialogBox.prompt("What is your name?","Anonymous");
Note that hitting the ESC key is equivalent to pressing the CANCEL button, and hitting the ENTER key is equivalent to pressing the OK button. The second parameter is optional; if defined, the text input field will be prepopulated with this value.

---

How do I catch the response of the end user?
The dialog box is dismissed if the end user presses any of the response buttons, the close button of the titlebar, or hit the ESC or ENTER key in the case of the PromptBox. When the dialog box is closed, the onResponse event handler is triggered. In the case of the AlertBox, it doesn't matter what the user clicked to close the dialog box, and the onResponse event is usually used to just tell the application to proceed.
Example:
myDialogBox.onResponse = function()
{
// dialog box dismissed, do next thing
}
myDialogBox.alert("You have new mail!");


In the case of the ConfirmBox, if you use the default buttons, you will receive either 'true' or 'false'.
Example:
myDialogBox.onResponse = function(result)
{
if (result)
{
// user clicked 'OK'
}
else
{
// user clicked 'Cancel'
}
}
myDialogBox.confirm("Do you wish to logout?");


If you use customized buttons for the ConfirmBox, you will receive the label of the button clicked.
Example:
myDialogBox.onResponse = function(result)
{
switch (result)
{
case "Yes":
// user clicked 'Yes'
break;
case "No":
// user clicked 'No'
break;
case "Cancel":
// user clicked 'Cancel'
}
}
myDialogBox.confirm("Save changes to Untitled-1?",["Yes","No","Cancel"]);


In the case of the PromptBox, you will receive the text input of the user if the user dismissed the dialog box by clicking the OK button or hitting the ENTER key, 'undefined' if the close button on the titlebar was clicked, or 'false' if the Cancel button or the ESC key was used.
Example:
myDialogBox.onResponse = function(result)
{
if (result!=undefined&&result!=false)
{
// result is text input
}
else
{
// cancelled
}
}
myDialogBox.prompt("What is your name?");


---

How can I change the labels on the OK and Cancel buttons?
You can set the labels on the OK and Cancel buttons by using the method
GWDialogBox.setButtonLabels(okButtonLabel, cancelButtonLabel);

---

How can I set the title and titlebar icon of the dialog box?
By default, the AlertBox's title will be "Alert", the ConfirmBox's title will be "Confirm" and the PromptBox's title will be "Prompt". You can set the title (and optionally an icon) by using the methods
GWDialogBox.setAlertTitle(title,icon);
GWDialogBox.setConfirmTitle(title,icon);
GWDialogBox.setPromptTitle(title,icon);

Call the respective method before calling the next alert(), confirm() or prompt() to set the dialog box's title and icon. Note that changes are 'persistent' - example, once you set a customized title for an AlertBox, it would be the same for all subsequent alert() calls, until/unless you call setAlertTitle() again.

---

How can I set the size of the dialog box?
The height of the dialog box is dependent on the contents and is determined automatically; you cannot specify the height. You can specify the width of the dialog box during runtime by using the method
GWDialogBox.setSize(width);
During authoring time, you can specify the width of the dialog box by scaling the component on the Stage. This width specified during authoring time will be the initial width of the dialog box.
Note also that the width of the dialog box will expand to accommodate custom buttons, if any, of the ConfirmBox.
The maximum width/height of a dialog box is the movieclip's width and height (Stage.width, Stage.height).


Flash Components
Button :: CheckBox :: CollapsibleMenu :: CollapsiblePane :: ColorPicker :: ComboBox :: ContextMenu :: DialogBox :: InputField :: ListBox :: Loader :: Menu :: SlideMenu :: NumericBox :: Panel :: ProgressBar :: RadioButton :: ScrollBar :: ScrollPane :: SlidePane :: Slider :: TabView :: TextArea :: TreeView :: Window

See also
Documentation :: FAQs :: Testimonials
 
Contact UsSite Map
Copyright © 2003-2006 GhostWire Studios