ComboBox

Kind of class:class
Inherits from:EventMovieClip < MovieClip
Implements:
Author:Martijn de Visser
Classpath:org.asapframework.ui.combobox.ComboBox
File last modified:Monday, 20 November 2006, 11:03:46
ComboBox class to create ComboBox UI elements with.
To do:
  • Implement removal of items

Summary


Constructor
Instance properties
Instance methods
  • mAdd (inItem:Object, inPosition:Number) : Void
    • Adds an item to the list
  • action : Void
    • Opens or closes the dropdown
  • dropDirection : Boolean
    • Determine if we need to drop down or drop up
  • update : Void
    • Updates visible items and scrollbar
  • updateItems : Void
    • Attaches items to show (to max set by rowCount, or deafult 5)
  • updateContent (inPosition:Number) : Void
    • Updates the content of the visible items
  • updateScrollBar : Void
    • Updates length of scrollbar and hides / shows it
  • updateSelection (inIndex:Number) : Void
    • updates the Label
  • placeClips (inDown:Boolean) : Number
    • Places clips before showing them
  • addItem (inItem:Object) : Void
    • PUBLIC
  • addItemAt (inItem:Object, inPosition:Number) : Void
    • adds an item to the dropdown list at a specific position.
  • getItemAt (inIndex:Number) : Object
    • Retrieves the item at a specified index.
  • show (inAnim:Boolean) : Void
    • Opens the dropdown
  • hide (inAnim:Boolean) : Void
    • Closes the dropdown
  • clear : Void
    • Clears contents of the ComboBox
  • getValue : Object
    • Gets the value of currently selected item (data field by default, or label if no data is available).
  • getScrollPosition : Number
    • ISCROLLABLE IMPLEMENTATION *
  • getTotalHeight : Number
    • IScrollable implementation: Returns the height of all content
  • getVisibleHeight : Number
    • IScrollable implementation: Returns the height of the visible content
  • scrollTo (inPos:Number) : Void
    • IScrollable implementation: Scrolls the content list up or down
  • getEnabled : Boolean
    • Gets the enabled state of the DropDown
  • setEnabled (inValue:Boolean) : Void
    • Sets the enabled state of the DropDown
  • getStepSize : Number
  • toString : String
Event handlers

Constructor

ComboBox

function ComboBox (
)

DropDown class

Instance properties

direction

direction
(read,write)

Sets / gets the drop direction. Values are: "up", "down" or "auto"

duration

duration
(write)

Setsthe duration of the dropdown animation (default 10)

itemClass

itemClass
(read,write)

Sets / gets the LinkageID to use for dropdown items. Default is "DropDownItem".

itemHeight

itemHeight
(read,write)

Sets / gets the item height (default 18)

label

label
(write)

Sets the inital label, shown if no items are selected

length

length:Number
(read)

Gets the length of the drop-down list.

mArrow

private mArrow:EventButton
(read)

mBackgroundMover

private mBackgroundMover:Tween
(read)

mc

private mc:MovieClip
(read)

mClipDepth

private mClipDepth:Number
(read)

mContentMover

private mContentMover:Tween
(read)

mData

private mData:Array
(read)

mDirection

private mDirection:String
(read)

mEnabled

private mEnabled:Boolean
(read)

mItemClass

private mItemClass:String
(read)

mItemHeight

private mItemHeight:Number
(read)

mItems

private mItems:Array
(read)

mLabel

private mLabel:TextField
(read)

mLabelText

private mLabelText:String
(read)

mListContent

private mListContent:MovieClip
(read)

mListContentBg

private mListContentBg:MovieClip
(read)

mListMask

private mListMask:MovieClip
(read)

mMaskAnchor

private mMaskAnchor:Number
(read)

mNeedUpdate

private mNeedUpdate:Boolean
(read)

mOpen

private mOpen:Boolean
(read)

mRowCount

private mRowCount:Number
(read)

mScrollBar

private mScrollBar:ScrollBar
(read)

mScrollBarMover

private mScrollBarMover:Tween
(read)

mScrollPosition

private mScrollPosition:Number
(read)

mSelectedIndex

private mSelectedIndex:Number
(read)

mShowDepth

private mShowDepth:Number
(read)

mTextFormat

private mTextFormat:TextFormat
(read)

mTweenDuration

private mTweenDuration:Number
(read)

open

open:Boolean
(read)

rowCount

rowCount
(read,write)

Sets / gets the the number of items to display in list

selectedIndex

selectedIndex
(read,write)

GETTER / SETTER *

selectedItem

selectedItem:Object
(read)

Gets the selected item, returns an object { label, data }

textFormat

textFormat
(write)

Sets the TextFormat of the label

value

value:Object
(read)

Gets the value of currently selected item (data field by default, or label if no data is available).

Instance methods

action

private function action (
) : Void

Opens or closes the dropdown

addItem

function addItem (
inItem:Object) : Void

PUBLIC

addItemAt

function addItemAt (
inItem:Object, inPosition:Number) : Void

adds an item to the dropdown list at a specific position. See addItem for details.

clear

function clear (
) : Void

Clears contents of the ComboBox

dropDirection

private function dropDirection (
) : Boolean

Determine if we need to drop down or drop up
Returns:
  • Boolean, true if we can drop down (preferred direction)

getEnabled

function getEnabled (
) : Boolean

Gets the enabled state of the DropDown

getItemAt

function getItemAt (
inIndex:Number) : Object

Retrieves the item at a specified index.
Parameters:
index:
The index of the item to retrieve. The index must be a number greater than or equal to 0, and less than the value of ComboBox.length.
Returns:
  • The indexed item object as { data, label }.

getScrollPosition

function getScrollPosition (
) : Number

ISCROLLABLE IMPLEMENTATION *

getStepSize

function getStepSize (
) : Number

getTotalHeight

function getTotalHeight (
) : Number

IScrollable implementation: Returns the height of all content

getValue

function getValue (
) : Object

Gets the value of currently selected item (data field by default, or label if no data is available).

getVisibleHeight

function getVisibleHeight (
) : Number

IScrollable implementation: Returns the height of the visible content

hide

function hide (
inAnim:Boolean) : Void

Closes the dropdown
Parameters:
inAnim:
, boolean, set to false to *skip* dropdown animation

mAdd

private function mAdd (
inItem:Object, inPosition:Number) : Void

Adds an item to the list

placeClips

private function placeClips (
inDown:Boolean) : Number

Places clips before showing them
Returns:
  • Number, vertical anchor point where all clips are aligned to

scrollTo

function scrollTo (
inPos:Number) : Void

IScrollable implementation: Scrolls the content list up or down

setEnabled

function setEnabled (
inValue:Boolean) : Void

Sets the enabled state of the DropDown

show

function show (
inAnim:Boolean) : Void

Opens the dropdown
Parameters:
inAnim:
, boolean, set to false to *skip* dropdown animaition

toString

function toString (
) : String

update

private function update (
) : Void

Updates visible items and scrollbar

updateContent

private function updateContent (
inPosition:Number) : Void

Updates the content of the visible items

updateItems

private function updateItems (
) : Void

Attaches items to show (to max set by rowCount, or deafult 5)

updateScrollBar

private function updateScrollBar (
) : Void

Updates length of scrollbar and hides / shows it

updateSelection

private function updateSelection (
inIndex:Number) : Void

updates the Label

Event handlers

onButtonClicked

function onButtonClicked (

Fired by arrow

onItemClicked

function onItemClicked (

EVENTS *

onLoad

private function onLoad (
) : Void

onMouseDown

function onMouseDown (
) : Void

Catch global onMouseDown event to close when clicking elsewhere

onMouseUp

function onMouseUp (
) : Void

Catch global onMouseUp event to close when clicking elsewhere, after dragging off the dropdown

onMouseWheel

function onMouseWheel (
inDelta:Number) : Void

Catches onMouseWheel event and passes it to the ScrollBar

onScrollContent

function onScrollContent (
e:ScrollEvent) : Void

IScrollable implementation: Scrolls the content list up or down

onUnload

private function onUnload (
) : Void