#

API Documentation for: NEXT
Show: Inherited Protected Private Deprecated

# ButtonHelper Class

Defined in: `ButtonHelper:39`
Module: EaselJS

The ButtonHelper is a helper class to create interactive buttons from MovieClip or Sprite 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.

Note that over states will not work unless you call enableMouseOver.

#### 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:39`

#### Parameters:

- `target` Sprite | 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. *

- Index
- Methods
- Properties

## Item Index

### Methods

- getEnabled deprecated
- handleEvent
- initialize
- setEnabled deprecated
- toString

### Properties

- _enabled
- _isOver
- _isPressed
- downLabel
- enabled
- outLabel
- overLabel
- play
- target

## Methods

### `getEnabled`

() Boolean deprecated

Defined in `getEnabled:145`

Deprecated: in favour of the enabled property.

Returns enabled state of this instance.

#### Returns:

Boolean:

The last value passed to setEnabled().

### `handleEvent`

(

- `evt`

)
protected

Defined in `handleEvent:232`

#### Parameters:

- `evt` Object

  The mouse event to handle.

### `initialize`

(

- `target`
- `[outLabel="out"]`
- `[overLabel="over"]`
- `[downLabel="down"]`
- `[play=false]`
- `[hitArea]`
- `[hitLabel]`

)
protected

Defined in `initialize:184`

Initialization method.

#### Parameters:

- `target` Sprite | 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.

### `setEnabled`

(

- `value`

)
deprecated

Defined in `setEnabled:122`

Deprecated: in favour of the enabled property.

Enables or disables the button functionality on the target.

#### Parameters:

- `value` Boolean

### `toString`

() String

Defined in `toString:221`

Returns a string representation of this object.

#### Returns:

String:

a string representation of the instance.

## Properties

### `_enabled`

Boolean protected

Defined in `_enabled:176`

### `_isOver`

Boolean protected

Defined in `_isOver:169`

### `_isPressed`

Boolean protected

Defined in `_isPressed:162`

### `downLabel`

String | Number

Defined in `downLabel:100`

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

### `enabled`

Boolean

Defined in `enabled:117`

Enables or disables the button functionality on the target.

### `outLabel`

String | Number

Defined in `outLabel:93`

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

### `overLabel`

String | Number

Defined in `overLabel:86`

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

### `play`

Boolean

Defined in `play:107`

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

Default: false

### `target`

MovieClip | Sprite

Defined in `target:78`

The target for this button helper.