# DisplayObject Class

Extends EventDispatcher
Defined in: `js/display/DisplayObject.js:15`
Module: view
Parent Module: StructureJS

The DisplayObject class is the base class for all objects that can be placed on the display list.

## Index

Show: Inherited Protected Private Deprecated

### Properties

- _listeners
- alpha
- ctx
- height
- isCreated
- isEnabled
- mouseEnabled
- name
- parent
- rotation
- scaleX
- scaleY
- sjsId
- stage
- unscaledHeight
- unscaledWidth
- useHandCursor
- visible
- width
- x
- y

### Methods

- DisplayObject constructor
- addEventListener
- addEventListenerOnce
- create
- destroy
- disable
- dispatchEvent
- enable
- getEventListeners
- getQualifiedClassName
- hasEventListener
- layout
- removeEventListener

## Properties

### `_listeners` Array. protected

Inherited from EventDispatcher: `js/event/EventDispatcher.js:39`

Holds a reference to added listeners.

### `alpha` Number public

Defined in `js/display/DisplayObject.js:126`

Indicates the alpha transparency value of the object specified.

### `ctx` CanvasRenderingContext2D public

Defined in `js/display/DisplayObject.js:39`

The CanvasRenderingContext2D interface provides the 2D rendering context for the drawing surface of a canvas element. This property is only used with the canvas specific display objects.

### `height` Number public

Defined in `js/display/DisplayObject.js:75`

Indicates the height of the display object, in pixels.

Default: 0

### `isCreated` Boolean public

Defined in `js/display/DisplayObject.js:158`

The isCreated property is used to keep track if it is the first time this DisplayObject is created.

Default: false

### `isEnabled` Boolean public

Inherited from ObjectManager: `js/ObjectManager.js:31`

The isEnabled property is used to keep track of the enabled state of the object.

Default: false

### `mouseEnabled` Boolean public

Defined in `js/display/DisplayObject.js:142`

Specifies whether this object receives mouse

### `name` String public

Defined in `js/display/DisplayObject.js:167`

Indicates the instance name of the DisplayObject.

### `parent` Any public

Inherited from EventDispatcher: `js/event/EventDispatcher.js:47`

Indicates the object that contains a child object. Uses the parent property to specify a relative path to display objects that are above the current display object in the display list hierarchy and helps facilitate event bubbling.

### `rotation` Number public

Defined in `js/display/DisplayObject.js:118`

Indicates the rotation of the DisplayObject instance, in degrees, from its original orientation.

### `scaleX` Number public

Defined in `js/display/DisplayObject.js:102`

Indicates the horizontal scale (percentage) of the object as applied from the registration point.

### `scaleY` Number public

Defined in `js/display/DisplayObject.js:110`

Indicates the vertical scale (percentage) of an object as applied from the registration point of the object.

### `sjsId` Int public

Inherited from BaseObject: `js/BaseObject.js:27`

The sjsId (StructureJS ID) is a unique identifier automatically assigned to most StructureJS objects upon instantiation.

Default: null

### `stage` Any public

Defined in `js/display/DisplayObject.js:31`

The Stage of the display object.

### `unscaledHeight` Number public

Defined in `js/display/DisplayObject.js:93`

A property providing access to the unscaledHeight.

Default: 100

### `unscaledWidth` Number public

Defined in `js/display/DisplayObject.js:84`

A property providing access to the unscaledWidth.

Default: 100

### `useHandCursor` Boolean public

Defined in `js/display/DisplayObject.js:150`

A Boolean value that indicates whether the pointing hand (hand cursor) appears when the pointer rolls over a display object.

### `visible` Boolean public

Defined in `js/display/DisplayObject.js:134`

Whether or not the display object is visible.

### `width` Number public

Defined in `js/display/DisplayObject.js:66`

Indicates the width of the display object, in pixels.

Default: 0

### `x` Number public

Defined in `js/display/DisplayObject.js:48`

A property providing access to the x position.

Default: 0

### `y` Number public

Defined in `js/display/DisplayObject.js:57`

A property providing access to the y position.

Default: 0

There are no properties that match your current filter settings. You can change your filter settings in the index section on this page. index

## Constructor

### `DisplayObject` ()

Defined in `js/display/DisplayObject.js:15`

## Methods

### `addEventListener`
(

- `type`
- `callback`
- `scope`
- `[priority=0]`

)
public chainable

Inherited from EventDispatcher: `js/event/EventDispatcher.js:59`

Registers an event listener object with an EventDispatcher object so the listener receives notification of an event.

#### Parameters:

- `type` String

  The type of event.

- `callback` Function

  The listener function that processes the event. This function must accept an Event object as its only parameter and must return nothing, as this example shows. @example function(event:Event):void

- `scope` Any

  Binds the scope to a particular object (scope is basically what "this" refers to in your function). This can be very useful in JavaScript because scope isn't generally maintained.

- `[priority=0]` Int optional

  Influences the order in which the listeners are called. Listeners with lower priorities are called after ones with higher priorities.

#### Example:

     this.addEventListener(BaseEvent.CHANGE, this._handlerMethod, this);

     _handlerMethod(event) {
         console.log(event.target + " sent the event.");
         console.log(event.type, event.data);
     }

### `addEventListenerOnce`
(

- `type`
- `callback`
- `scope`
- `[priority=0]`

)
public chainable

Inherited from EventDispatcher: `js/event/EventDispatcher.js:102`

Registers an event listener object once with an EventDispatcher object so the listener will receive the notification of an event.

#### Parameters:

- `type` String

  The type of event.

- `callback` Function

  The listener function that processes the event. This function must accept an Event object as its only parameter and must return nothing, as this example shows. @example function(event:Event):void

- `scope` Any

  Binds the scope to a particular object (scope is basically what "this" refers to in your function). This can be very useful in JavaScript because scope isn't generally maintained.

- `[priority=0]` Int optional

  Influences the order in which the listeners are called. Listeners with lower priorities are called after ones with higher priorities.

#### Example:

     this.addEventListenerOnce(BaseEvent.CHANGE, this._handlerMethod, this);

     _handlerMethod(event) {
         console.log(event.target + " sent the event.");
         console.log(event.type, event.data);
     }

### `create` () DisplayObject public chainable

Defined in `js/display/DisplayObject.js:176`

The create function is intended to provide a consistent place for the creation or initializing the view. It will automatically be called the first time that the view is added to a DisplayObjectContainer. It is critical that all subclasses call the super for this function in their overridden methods.

#### Returns:

DisplayObject:

Returns an instance of itself.

### `destroy` () Void public

Inherited from BaseObject: `js/BaseObject.js:55`

The purpose of the destroy method is to make an object ready for garbage collection. This should be thought of as a one way function. Once destroy is called no further methods should be called on the object or properties accessed. It is the responsibility of those who implement this function to stop all running Timers, all running Sounds, and take any other steps necessary to make an object eligible for garbage collection.

By default the destroy method will null out all properties of the class automatically. You should call destroy on other objects before calling the super.

#### Returns:

Void:

#### Example:

    destroy() {
         this.disable();

         this._childInstance.destroy();

         super.destroy();
    }

### `disable` () public chainable

Inherited from ObjectManager: `js/ObjectManager.js:64`

The disable method is responsible for disabling event listeners and/or children of the containing objects.

#### Example:

     disable() {
         if (this.isEnabled === false) { return this; }

         this._childInstance.removeEventListener(BaseEvent.CHANGE, this.handlerMethod, this);
         this._childInstance.disable();

         return super.disable();
     }

### `dispatchEvent`
(

- `event`
- `[data=null]`

)
public chainable

Inherited from EventDispatcher: `js/event/EventDispatcher.js:159`

Dispatches an event into the event flow. The event target is the EventDispatcher object upon which the dispatchEvent() method is called.

#### Parameters:

- `event` String | BaseEvent

  The Event object or event type string you want to dispatch. You can create custom events, the only requirement is all events must extend BaseEvent.

- `[data=null]` Any optional

  The optional data you want to send with the event. Do not use this parameter if you are passing in a BaseEvent.

#### Example:

     this.dispatchEvent('change');

     // Example: Sending data with the event:
     this.dispatchEvent('change', {some: 'data'});

     // Example: With an event object
     // (event type, bubbling set to true, cancelable set to true and passing data) :
     let event = new BaseEvent(BaseEvent.CHANGE, true, true, {some: 'data'});
     this.dispatchEvent(event);

     // Here is a common inline event object being dispatched:
     this.dispatchEvent(new BaseEvent(BaseEvent.CHANGE));

### `enable` () public chainable

Inherited from ObjectManager: `js/ObjectManager.js:41`

The enable method is responsible for enabling event listeners and/or children of the containing objects.

#### Example:

    enable() {
         if (this.isEnabled === true) { return this; }

         this._childInstance.addEventListener(BaseEvent.CHANGE, this.handlerMethod, this);
         this._childInstance.enable();

         return super.enable();
    }

### `getEventListeners` () String public

Inherited from EventDispatcher: `js/event/EventDispatcher.js:248`

Generates a string output of event listeners for a given object.

#### Returns:

String:

#### Example:

     this.getEventListeners();

     // [ClassName] is listening for the 'BaseEvent.change' event.

### `getQualifiedClassName` () String public

Inherited from BaseObject: `js/BaseObject.js:40`

Returns the fully qualified class name of an object.

#### Returns:

String:

Returns the class name.

#### Example:

    let someClass = new SomeClass();
    someClass.getQualifiedClassName();

    // SomeClass

### `hasEventListener`
(

- `type`
- `callback`
- `scope`

)
Boolean public

Inherited from EventDispatcher: `js/event/EventDispatcher.js:223`

Check if an object has a specific event listener already added.

#### Parameters:

- `type` String

  The type of event.

- `callback` Function

  The listener method to call.

- `scope` Any

  The scope of the listener object.

#### Returns:

Boolean:

#### Example:

     this.hasEventListener(BaseEvent.CHANGE, this._handlerMethod, this);

### `layout` () DisplayObject public chainable

Defined in `js/display/DisplayObject.js:190`

The layout method provides a common function to handle updating objects in the view.

#### Returns:

DisplayObject:

Returns an instance of itself.

### `removeEventListener`
(

- `type`
- `callback`
- `scope`

)
public chainable

Inherited from EventDispatcher: `js/event/EventDispatcher.js:131`

Removes a specified listener from the EventDispatcher object.

#### Parameters:

- `type` String

  The type of event.

- `callback` Function

  The listener object to remove.

- `scope` Any

  The scope of the listener object to be removed.

#### Example:

     this.removeEventListener(BaseEvent.CHANGE, this._handlerMethod, this);

There are no methods that match your current filter settings. You can change your filter settings in the index section on this page. index