# AnimEvents

Class · category: Animation

Source: https://github.com/playcanvas/engine/blob/f059dc005842f76e052cdf44d8370c8c7ec475ac/src/framework/anim/evaluator/anim-events.js#L10

AnimEvents stores a sorted array of animation events which should fire sequentially during the
playback of an [AnimTrack](https://api.playcanvas.com/engine/classes/AnimTrack.md). Each event is an object with a `name` and a `time` in
seconds plus any extra properties you attach. When playback passes an event's time it is fired
on the [AnimComponent](https://api.playcanvas.com/engine/classes/AnimComponent.md) under the event's name, so a script listens with
`entity.anim.on('footstep', callback)` and receives the event object.

## Constructors

### constructor

```ts
new AnimEvents(events: any[])
```

Create a new AnimEvents instance.

**Parameters**

- `events` (`any[]`): An array of animation events.

**Example**

```ts
const events = new AnimEvents([
    {
        name: 'my_event',
        time: 1.3, // given in seconds
        // any additional properties added are optional and will be available in the EventHandler callback's event object
        myProperty: 'test',
        myOtherProperty: true
    }
]);
animTrack.events = events;
```
