#

API Documentation for: 0.8.1
Show: Inherited Protected Private Deprecated

# ButtonHelper Class

Defined in: `ButtonHelper:41`
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:41`

#### 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

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

### Properties

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

## Methods

### `_reset`

() protected

Defined in `_reset:255`

Injected into target. Preserves the paused state through a reset.

### `getEnabled`

() Boolean deprecated

Defined in `getEnabled:194`

Use the enabled property instead.

#### Returns:

Boolean:

### `handleEvent`

(

- `evt`

)
protected

Defined in `handleEvent:228`

#### Parameters:

- `evt` Object

  The mouse event to handle.

### `initialize`

() deprecated protected

Defined in `initialize:153`

REMOVED. Removed in favor of using `MySuperClass_constructor`. See extend and promote for details.

There is an inheritance tutorial distributed with EaselJS in /tutorials/Inheritance.

### `setEnabled`

(

- `value`

)
deprecated

Defined in `setEnabled:168`

Use the enabled property instead.

#### Parameters:

- `value` Boolean

### `toString`

() String

Defined in `toString:217`

Returns a string representation of this object.

#### Returns:

String:

a string representation of the instance.

## Properties

### `_enabled`

Boolean protected

Defined in `_enabled:132`

### `_isOver`

Boolean protected

Defined in `_isOver:125`

### `_isPressed`

Boolean protected

Defined in `_isPressed:118`

### `downLabel`

String | Number

Defined in `downLabel:101`

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

### `enabled`

Boolean

Defined in `enabled:204`

Enables or disables the button functionality on the target.

### `outLabel`

String | Number

Defined in `outLabel:94`

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

### `overLabel`

String | Number

Defined in `overLabel:87`

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

### `play`

Boolean

Defined in `play:108`

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

Default: false

### `target`

MovieClip | Sprite

Defined in `target:79`

The target for this button helper.