1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//Instantiate and get the instance from the element's data-spriteClip property
var instance = $(".awesome-button").spriteClip({
    totalFrames: 30,
    frameRate: 60,
    stops: [1, 30]
}).data("spriteClip");
 
//Equivalent to
//var instance = new SpriteClip($(".awesome-button").get(0), {
//    totalFrames: 30,
//    frameRate: 60,
//    stops: [1, 30]
//})
 
instance.$elem.on("mouseover", function () {
    instance.play();
})
.on("mouseout", function () {
    instance.rewind();
});
 
instance.$dispatcher.on(SpriteClipEvent.ENTER_FRAME, function () {
    $(".currentFrame span").text(instance.currentFrame);
});