DialogBox

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.

Summary
DialogBoxA base class dialog box widget.
Private constants
MARGINSize of margins in pixels.
MarginLeftWidth of the margin used for the left hand border.
MarginTopHeight of the margin used in the title bar.
MarginRightWidth of the margin used for the rifght hand border.
MarginBottomHeight of the margin used for the bottom border.
Private properties
sizeXWidth of the dialog box including borders.
sizeYHeight of the dialog box including title bar and bottom border.
bgColorBase background theme color for the dialog chrome.
bgTransparencyTransparency of the dialog box (alpha 0-1).
windowTextTitle bar text label
closeButtonClose button for cancelling the dialog.
isMovingState variable indicating if the dialog is being moved/dragged.
Public properties
closeHandlerCallback function called when the dialog is closed.
clientAreaThe dialog client area where a derived class can place widgets and other display objects.
Constructor
DialogBoxCreates a dialogbox with a client area of the given size.
Title bar text
titleTextRetrieve the dialog title bar text string.
titleTextChange the dialog title bar text to the newTitle string.
positionTitlePlaces the dialog title text in the title bar.
Event handlers
DismissCloses a dialog, either cancelling or accepting it.
mouseCloseHandlerCalled when the user clicks on the dialog close button.
mouseDownHandlerBrings the dialog to the foreground and initiates a dragging operation on the dialog box when the user clicks on the title/border area -
mouseUpHandlerDrops a dialog box at the current position if it is being dragged.
mouseOutHandlerForwards a mouse out event to the mouse up handler.
Drawing methods
drawWindowDraws the dialog box outline, title and border area.
drawClientAreaDraws the dialog client area with an inset border.
addDropShadowApplies a drop shadow to a sprite
getBitmapFilterCreates a simple drop shadow filter
WidgetInterface
activeSets the state of the widget to active or inactive.
activateActivates the widget, adds its event listeners
disactivateDisactivates the widget, removes its event listeners
disposeDispose of all resources used or referenced in the instance.
destructorRemoves used resources, references and graphics.

Private constants

MARGIN

private const MARGIN: uint

Size of margins in pixels.

MarginLeft

private const MarginLeft: uint

Width of the margin used for the left hand border.

MarginTop

private const MarginTop: uint

Height of the margin used in the title bar.

MarginRight

private const MarginRight: uint

Width of the margin used for the rifght hand border.

MarginBottom

private const MarginBottom: uint

Height of the margin used for the bottom border.

Private properties

sizeX

private var sizeX: uint

Width of the dialog box including borders.

sizeY

private var sizeY: uint

Height of the dialog box including title bar and bottom border.

bgColor

private var bgColor: uint

Base background theme color for the dialog chrome.

bgTransparency

private var bgTransparency: Number

Transparency of the dialog box (alpha 0-1).

windowText

private var windowText: Label

Title bar text label

closeButton

private var closeButton: BubbleButton

Close button for cancelling the dialog.

isMoving

private var isMoving: Boolean

State variable indicating if the dialog is being moved/dragged.

Public properties

closeHandler

public var closeHandler: Function

Callback function called when the dialog is closed.  The function receives one boolean argument, true if the dialog was accepted, false otherwise.

Callback

closeHandlerfunction onDialogBoxClose(accepted:Boolean):void

clientArea

public var clientArea: Sprite

The dialog client area where a derived class can place widgets and other display objects.

Constructor

DialogBox

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.

Parameters

titledialog box displayed title
widthclient area width
heightclient area height
borderColorbase theme color used in drawing the dialog border (default is black)
backgroundTransparencyalpha level of the dialog (default is not transparent)

Title bar text

titleText

public function get titleText():String

Retrieve the dialog title bar text string.

titleText

public function set titleText(newTitle: String):void

Change the dialog title bar text to the newTitle string.

positionTitle

private function positionTitle():void

Places the dialog title text in the title bar.  Calculates the position as centered if there is sufficient room for the text else left aligned.

Event handlers

Dismiss

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.

Parameters

acceptedtrue if the dialog was accepted, false otherwise.

mouseCloseHandler

private function mouseCloseHandler(event: MouseEvent):void

Called when the user clicks on the dialog close button.  Dismisses the dialog as if a cancel button was pressed.

mouseDownHandler

private function mouseDownHandler(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 -

mouseUpHandler

private function mouseUpHandler(event: MouseEvent):void

Drops a dialog box at the current position if it is being dragged.

mouseOutHandler

private function mouseOutHandler(event: MouseEvent):void

Forwards a mouse out event to the mouse up handler.  Effectively it drops a dialogbox being dragged if the mouse leaves the area where the dialog can be dragged.

Drawing methods

drawWindow

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.

Parameters

spritedialog display object
colordialog base theme color

drawClientArea

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.

Parameters

spriteclient area display object
colorclient area background color (dialog theme color)
widthclient area width in pixels
heightclient area height in pixels

addDropShadow

private function addDropShadow(sprite: Sprite):void

Applies a drop shadow to a sprite

Parameters

spriteobject to add the filter to

getBitmapFilter

private function getBitmapFilter():BitmapFilter

Creates a simple drop shadow filter

Returns

A dropshadow bitmap filter

WidgetInterface

active

public function set active(state: Boolean):void

Sets the state of the widget to active or inactive.

Parameters

stateTrue to activate, false otherwise.

activate

private function activate():void

Activates the widget, adds its event listeners

disactivate

private function disactivate():void

Disactivates the widget, removes its event listeners

dispose

public function dispose():void

Dispose of all resources used or referenced in the instance.

destructor

private function destructor():void

Removes used resources, references and graphics.  Cleans up widgets and display objects on the client area on behalf of the owning/derived class.

Widgets are required to implement this interface.
Base class for widgets to enable/disable event listeners and keep a global tab order of all widgets (provided they are created and registered in tab order.
Color selection dialog based on the hue, saturation, brightness color space.
A dialog with a short message for the user to confirm or cancel an operation.
User interface for display, import and editing of generated script code.
User interface for selection of layer (scene node) properties.
User interface for timeline tween property selection.
private const MARGIN: uint
Size of margins in pixels.
private const MarginLeft: uint
Width of the margin used for the left hand border.
private const MarginTop: uint
Height of the margin used in the title bar.
private const MarginRight: uint
Width of the margin used for the rifght hand border.
private const MarginBottom: uint
Height of the margin used for the bottom border.
private var sizeX: uint
Width of the dialog box including borders.
private var sizeY: uint
Height of the dialog box including title bar and bottom border.
private var bgColor: uint
Base background theme color for the dialog chrome.
private var bgTransparency: Number
Transparency of the dialog box (alpha 0-1).
private var windowText: Label
Title bar text label
private var closeButton: BubbleButton
Close button for cancelling the dialog.
private var isMoving: Boolean
State variable indicating if the dialog is being moved/dragged.
public var closeHandler: Function
Callback function called when the dialog is closed.
public var clientArea: Sprite
The dialog client area where a derived class can place widgets and other display objects.
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.
public function get titleText():String
Retrieve the dialog title bar text string.
private function positionTitle():void
Places the dialog title text in the title bar.
public function Dismiss(accepted: Boolean):void
Closes a dialog, either cancelling or accepting it.
private function mouseCloseHandler(event: MouseEvent):void
Called when the user clicks on the dialog close button.
private function mouseDownHandler(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 mouseUpHandler(event: MouseEvent):void
Drops a dialog box at the current position if it is being dragged.
private function mouseOutHandler(event: MouseEvent):void
Forwards a mouse out event to the mouse up handler.
private function drawWindow(sprite: Sprite,
color: uint):void
Draws the dialog box outline, title and border area.
private function drawClientArea(sprite: Sprite,
color: uint,
width: uint,
height: uint):void
Draws the dialog client area with an inset border.
private function addDropShadow(sprite: Sprite):void
Applies a drop shadow to a sprite
private function getBitmapFilter():BitmapFilter
Creates a simple drop shadow filter
public function set active(state: Boolean):void
Sets the state of the widget to active or inactive.
private function activate():void
Activates the widget, adds its event listeners
private function disactivate():void
Disactivates the widget, removes its event listeners
public function dispose():void
Dispose of all resources used or referenced in the instance.
private function destructor():void
Removes used resources, references and graphics.
Close