The main class in the library

var sprite:Aseprite = Aseprite.fromBytes(Assets.getBytes('path/to/asepriteAsset.aseprite'));
addChild(sprite);

Static methods

@:value({ useEnterFrame : true })staticfromBytes(bytes:Bytes, useEnterFrame:Bool = true):Aseprite

Create a Sprite from a Bytes instance

Parameters:

byteArray

ByteArray with file data

useEnterFrame

If true add an ENTER_FRAME event listener to advence the animation

Variables

read onlyase:Ase

Parsed Aseprite file data

@:value(0)currentFrame:Int = 0

Current frame index of the animation (0...frames.length)

@:value(null)currentTag:String = null

Current playing tag. Set to null in order to reset

direction:Int

Direction of the animation:

0 - Forward
1 - Reverse
2 - Ping-Pong

read onlyframes:Array<Frame>

Array of animation frames

read onlyfromFrame:Int

Starting frame of the animation or the current tag

read onlyisPlaying:Bool

read onlylayers:Array<LayerChunk>

List of layer chunks

read onlyonFrame:Array<Int ‑> Void>

An array of function that will be called on every frame change

sprite.onFrame.push((frameIndex:Int) -> {
  trace('Frame index changed to: ${frameIndex}');
});

read onlyonTag:Array<Array<String> ‑> Void>

An array of functions that will be called every time tags of the current frame are different from the tags of the previous frame

sprite.onTag.push((tags:Array<String>) -> {
  trace('Current tags are: ${tags.join(', ')}');
});

read onlypalette:Palette

Sprite's palette

for(index => color in sprite.palette.entries) {
  trace('Paletter entry $index: #${StringTools.hex(color, 6)}');
}

read onlyslice:Slice

If the sprite was created from a Slice represents the data of this Slice

read onlyslices:Map<String, Slice>

Array of Slices

read onlytags:Map<String, Tag>

Map of animation tags by names

read onlytoFrame:Int

Ending frame of the animation or the current tag

read onlytotalDuration:Int

The total duration of the sprite

useEnterFrame:Bool

If set to true will use ENTER_FRAME event to update the state of the sprite. Otherwise update time of the sprite manually

Methods

advance(time:Int):Aseprite

Advance animation by time milliseconds

Parameters:

time

Time in milliseconds

nextFrame():Aseprite

Go to the next frame respecting the direction of the current animation

pause():Aseprite

Pause the playback

@:value({ onFinished : null, repeats : -1, tagName : null })play(?tagName:String, repeats:Int = -1, ?onFinished:() ‑> Void):Aseprite

Start playing the animation

Parameters:

tagName

Name of the tag to play

repeats

Number of repeats (-1 - infinite)

onFinished

Callback that will be called when repeats are finished (won't be called if repeats == -1)

resize(newWidth:Int, newHeight:Int):Void

Resize all the frames

@:value({ useEnterFrame : null })spawn(?sliceName:String, ?spriteWidth:Int, ?spriteHeight:Int, ?useEnterFrame:Bool):Aseprite

Create a copy of this sprite bypassing file data parsing by reusing the resources

Parameters:

sliceName

Name of the slice to cut from the sprite

spriteWidth

Width of the newly created sprite.

spriteHeight

Height of the newly created sprite.

useEnterFrame

Use ENTER_FRAME event to advance the animation

stop():Aseprite

Pause the animation and bring the playhead to the first frame of the animation or the current tag