playing sprite just once

Hi,
I have what I think should be a simple problem. I would like to have a sprite of a coin that would randomly animates, this is my attempt

local coin_image = sprite.newSprite(sprite.newSpriteSet(sprite.newSpriteSheet(“shiny_coin.png”, 32, 32), 1, 5))
local function glimmer(event)
if math.random(3) == 1 then
coin_image:play()
end
end
timer.performWithDelay(1000, glimmer, 0)

all I want is when I hit play, it would play once, and when the randomness hits, it would play again. Is this the correct way of doing it? [import]uid: 11334 topic_id: 4136 reply_id: 304136[/import]

my second attempt is getting closer but after the animation is done, it will show again during the animation, any tips?
[lua] local coin_sheet = sprite.newSpriteSheet(“shiny_coin.png”, 32, 32)
local coin_set = sprite.newSpriteSet(coin_sheet , 1, 6)
sprite.add(coin_set, “shine”, 1, 6, 300, -1)
local coin_image = sprite.newSprite(coin_set)
coin_image:prepare(“shine”)
coin_image:play()
local function glimmer(event)
if math.random(3) == 1 then
coin_image:play()
end
end
timer.performWithDelay(1000, glimmer, 0)[/lua]
[import]uid: 11334 topic_id: 4136 reply_id: 12810[/import]