springroll.easeljs.SoundButton Class

A button with audio events for click and over mouse events

Constructor

springroll.easeljs.SoundButton

(
  • imageSettings
  • [label=null]
  • [enabled=true]
  • [clickAlias="ButtonClick"]
  • [overAlias="ButtonRollover"]
)

Parameters:

  • imageSettings DOMElement | Object

    The loaded image element, see springroll.easeljs.Button constructor

  • [label=null] Object optional

    See springroll.easeljs.Button constructor

  • [enabled=true] Boolean optional

    If the button should be enabled by default

  • [clickAlias="ButtonClick"] String optional

    The button click audio alias

  • [overAlias="ButtonRollover"] String optional

    The button rollover audio alias

_addProperty

(
  • propertyName
)
private

Adds a property to the button. Setting the property sets the value in _stateFlags and calls _updateState().

Parameters:

  • propertyName String

    The property name to add to the button.

_onButtonPress

()
private

Defined in _onButtonPress:58

Handler for the BUTTON_PRESS event

_onClick

()
private

The callback for when the button the button is clicked or tapped on. This is the most reliable way of detecting mouse up/touch end events that are on this button while letting the pressup event handle the mouse up/touch ends on and outside the button.

_onMouseDown

()
private

The callback for when the button receives a mouse down event.

_onMouseOut

()
private

The callback for when the mouse leaves the button area.

_onMouseOver

()
private

The callback for when the button is moused over.

_onMouseUp

()
private

The callback for when the button for when the mouse/touch is released on the button

  • only when the button was held down initially.

_onRollover

()
private

Defined in _onRollover:71

Handler for rollover event.

_updateState

() Object
private

Updates back based on the current button state.

Returns:

Object:

The state data for the active button state, so that subclasses can use the value picked by this function without needing to calculate it themselves.

cacheByBounds

(
  • [buffer=0]
  • [scale=1]
)

Does a cache by the nominalBounds set from Flash

Parameters:

  • [buffer=0] Int optional

    The space around the nominal bounds to include in cache image

  • [scale=1] Number optional

    The scale to cache the container by.

cacheByRect

(
  • rect
  • [buffer=0]
  • [scale=1]
)

Does a cache by a given rectangle

Parameters:

  • rect createjs.Rectangle

    The rectangle to cache with.

  • [buffer=0] Int optional

    Additional space around the rectangle to include in cache image

  • [scale=1] Number optional

    The scale to cache the container by.

destroy

()

Inherited from springroll.easeljs.Button but overwritten in destroy:121

Don't use after this

setText

(
  • text
)
public

Sets the text of the label. This does nothing if the button was not initialized with a label.

Parameters:

  • text String

    The text to set the label to.

_audioEnabled

Boolean private

Defined in _audioEnabled:38

If the audio is enabled

_clickCB

Function private

Callback for click, bound to this button.

_downCB

Function private

Callback for mouse down, bound to this button.

_height

Number private

The height of the button art, independent of the scaling of the button itself.

_offset

createjs.Point private

An offset to button positioning, generally used to adjust for a highlight around the button.

_outCB

Function private

Callback for mouse out, bound to this button.

_overCB

Function private

Callback for mouse over, bound to this button.

_stateData

Object private

A dictionary of state graphic data, keyed by state name. Each object contains the sourceRect (src) and optionally 'trim', another Rectangle. Additionally, each object will contain a 'label' object if the button has a text label.

_stateFlags

Object private

A dictionary of state booleans, keyed by state name.

_statePriority

Array private

An array of state names (Strings), in their order of priority. The standard order previously was ["highlighted", "disabled", "down", "over", "selected", "up"].

_upCB

Function private

Callback for press up, bound to this button.

_width

Number private

The width of the button art, independent of the scaling of the button itself.

audioEnabled

Boolean

Defined in audioEnabled:84

If audio should be played for this button.

back

createjs.Bitmap public

The sprite that is the body of the button.

clickAlias

String

Defined in clickAlias:26

The audio alias to use for click events

enabled

Boolean

Whether or not the button is enabled.

Default: true

height

Number

The height of the button, based on the height of back. This value is affected by scale.

label

createjs.Text public

The text field of the button. The label is centered by both width and height on the button.

overAlias

String

Defined in overAlias:32

The audio alias to use for mouse over events

width

Number

The width of the button, based on the width of back. This value is affected by scale.