A base class dialog box widget. The name used in registering the dialog as a widget is its initial title text. It is not automatically activated. The dialog is draggable and has a border area, title bar and close button.
See ConfirmForm for a simple dialog that can be used as a template.
DialogBox | A base class dialog box widget. |
Private constants | |
MARGIN | Size of margins in pixels. |
MarginLeft | Width of the margin used for the left hand border. |
MarginTop | Height of the margin used in the title bar. |
MarginRight | Width of the margin used for the rifght hand border. |
MarginBottom | Height of the margin used for the bottom border. |
Private properties | |
sizeX | Width of the dialog box including borders. |
sizeY | Height of the dialog box including title bar and bottom border. |
bgColor | Base background theme color for the dialog chrome. |
bgTransparency | Transparency of the dialog box (alpha 0-1). |
windowText | Title bar text label |
closeButton | Close button for cancelling the dialog. |
isMoving | State variable indicating if the dialog is being moved/dragged. |
Public properties | |
closeHandler | Callback function called when the dialog is closed. |
clientArea | The dialog client area where a derived class can place widgets and other display objects. |
Constructor | |
DialogBox | Creates a dialogbox with a client area of the given size. |
Title bar text | |
titleText | Retrieve the dialog title bar text string. |
titleText | Change the dialog title bar text to the newTitle string. |
positionTitle | Places the dialog title text in the title bar. |
Event handlers | |
Dismiss | Closes a dialog, either cancelling or accepting it. |
mouseCloseHandler | Called when the user clicks on the dialog close button. |
mouseDownHandler | Brings the dialog to the foreground and initiates a dragging operation on the dialog box when the user clicks on the title/border area - |
mouseUpHandler | Drops a dialog box at the current position if it is being dragged. |
mouseOutHandler | Forwards a mouse out event to the mouse up handler. |
Drawing methods | |
drawWindow | Draws the dialog box outline, title and border area. |
drawClientArea | Draws the dialog client area with an inset border. |
addDropShadow | Applies a drop shadow to a sprite |
getBitmapFilter | Creates a simple drop shadow filter |
WidgetInterface | |
active | Sets the state of the widget to active or inactive. |
activate | Activates the widget, adds its event listeners |
disactivate | Disactivates the widget, removes its event listeners |
dispose | Dispose of all resources used or referenced in the instance. |
destructor | Removes used resources, references and graphics. |
public function DialogBox( title: String, width: uint, height: uint, borderColor: uint = 0, backgroundTransparency: Number = 1.0 )
Creates a dialogbox with a client area of the given size. The dialog has a titlebar with a close button and a border around the client area. Normally this constructor should be called as super(...) in a derived dialog class constructor.
title | dialog box displayed title |
width | client area width |
height | client area height |
borderColor | base theme color used in drawing the dialog border (default is black) |
backgroundTransparency | alpha level of the dialog (default is not transparent) |
public function Dismiss( accepted: Boolean ):void
Closes a dialog, either cancelling or accepting it. The dialogs is removed from the display list and its event handlers are disactivated. The dialog is not destroyed and can be shown again by adding it to the display list and activating it. An optional user supplied close handler is called with the close state argument.
accepted | true if the dialog was accepted, false otherwise. |
private function drawWindow( sprite: Sprite, color: uint ):void
Draws the dialog box outline, title and border area. The coloring is chosen according to the palette type of the given dialog. The background is a radial gradient fill with a transparency level according to bgTransparency.
sprite | dialog display object |
color | dialog base theme color |
private function drawClientArea( sprite: Sprite, color: uint, width: uint, height: uint ):void
Draws the dialog client area with an inset border. The area fill is made transparent if the bgTransparency member is less than 1.
sprite | client area display object |
color | client area background color (dialog theme color) |
width | client area width in pixels |
height | client area height in pixels |
Size of margins in pixels.
private const MARGIN: uint
Width of the margin used for the left hand border.
private const MarginLeft: uint
Height of the margin used in the title bar.
private const MarginTop: uint
Width of the margin used for the rifght hand border.
private const MarginRight: uint
Height of the margin used for the bottom border.
private const MarginBottom: uint
Width of the dialog box including borders.
private var sizeX: uint
Height of the dialog box including title bar and bottom border.
private var sizeY: uint
Base background theme color for the dialog chrome.
private var bgColor: uint
Transparency of the dialog box (alpha 0-1).
private var bgTransparency: Number
Title bar text label
private var windowText: Label
Close button for cancelling the dialog.
private var closeButton: BubbleButton
State variable indicating if the dialog is being moved/dragged.
private var isMoving: Boolean
Callback function called when the dialog is closed.
public var closeHandler: Function
The dialog client area where a derived class can place widgets and other display objects.
public var clientArea: Sprite
Creates a dialogbox with a client area of the given size.
public function DialogBox( title: String, width: uint, height: uint, borderColor: uint = 0, backgroundTransparency: Number = 1.0 )
Retrieve the dialog title bar text string.
public function get titleText():String
Places the dialog title text in the title bar.
private function positionTitle():void
Closes a dialog, either cancelling or accepting it.
public function Dismiss( accepted: Boolean ):void
Called when the user clicks on the dialog close button.
private function mouseCloseHandler( event: MouseEvent ):void
Brings the dialog to the foreground and initiates a dragging operation on the dialog box when the user clicks on the title/border area -
private function mouseDownHandler( event: MouseEvent ):void
Drops a dialog box at the current position if it is being dragged.
private function mouseUpHandler( event: MouseEvent ):void
Forwards a mouse out event to the mouse up handler.
private function mouseOutHandler( event: MouseEvent ):void
Draws the dialog box outline, title and border area.
private function drawWindow( sprite: Sprite, color: uint ):void
Draws the dialog client area with an inset border.
private function drawClientArea( sprite: Sprite, color: uint, width: uint, height: uint ):void
Applies a drop shadow to a sprite
private function addDropShadow( sprite: Sprite ):void
Creates a simple drop shadow filter
private function getBitmapFilter():BitmapFilter
Sets the state of the widget to active or inactive.
public function set active( state: Boolean ):void
Activates the widget, adds its event listeners
private function activate():void
Disactivates the widget, removes its event listeners
private function disactivate():void
Dispose of all resources used or referenced in the instance.
public function dispose():void
Removes used resources, references and graphics.
private function destructor():void