API Documentation for: 0.6.1
Show:

ButtonHelper Class

Defined in: ButtonHelper:34
Module: EaselJS

The ButtonHelper is a helper class to create interactive buttons from MovieClip or BitmapAnimation instances. This class will intercept mouse events from an object, and automatically call gotoAndStop or gotoAndPlay, to the respective animation labels, add a pointer cursor, and allows the user to define a hit state frame.

The ButtonHelper instance does not need to be added to the stage, but a reference should be maintained to prevent garbage collection.

Example

 var helper = new createjs.ButtonHelper(myInstance, "out", "over", "down", false, myInstance, "hit");
 myInstance.addEventListener("click", handleClick);
 function handleClick(event) {
     // Click Happened.
 }

Constructor

ButtonHelper

(
  • target
  • [outLabel="out"]
  • [overLabel="over"]
  • [downLabel="down"]
  • [play=false]
  • [hitArea]
  • [hitLabel]
)

Defined in ButtonHelper:34

Parameters:

  • target BitmapAnimation | MovieClip

    The instance to manage.

  • [outLabel="out"] String optional

    The label or animation to go to when the user rolls out of the button.

  • [overLabel="over"] String optional

    The label or animation to go to when the user rolls over the button.

  • [downLabel="down"] String optional

    The label or animation to go to when the user presses the button.

  • [play=false] Boolean optional

    If the helper should call "gotoAndPlay" or "gotoAndStop" on the button when changing states.

  • [hitArea] DisplayObject optional

    An optional item to use as the hit state for the button. If this is not defined, then the button's visible states will be used instead. Note that the same instance as the "target" argument can be used for the hitState.

  • [hitLabel] String optional

    The label or animation on the hitArea instance that defines the hitArea bounds. If this is null, then the default state of the hitArea will be used.

Methods

handleEvent

() protected

Defined in handleEvent:178

initialize

() protected

Defined in initialize:124

Initialization method.

setEnabled

(
  • value
)

Defined in setEnabled:149

Enables or disables the button functionality on the target.

Parameters:

toString

() String

Defined in toString:167

Returns a string representation of this object.

Returns:

String: a string representation of the instance.

Properties

_isPressed

Boolean protected

Defined in _isPressed:109

_isPressed

Boolean protected

Defined in _isPressed:116

downLabel

String | Number

Defined in downLabel:93

The label name or frame number to display when the user presses on the target. Defaults to "down".

outLabel

String | Number

Defined in outLabel:86

The label name or frame number to display when the user mouses over the target. Defaults to "out".

overLabel

String | Number

Defined in overLabel:79

The label name or frame number to display when the user mouses out of the target. Defaults to "over".

play

Boolean

Defined in play:100

If true, then ButtonHelper will call gotoAndPlay, if false, it will use gotoAndStop. Default is false.

Default: false

target

MovieClip | BitmapAnimation

Defined in target:72

Read-only. The target for this button helper.