a sprite touch event does not work

Hi there…

I am new to corona… I have a RunTime touch event that created a running horse sprite, which works… I want the user to be able t touch the sprite and for the sprite to disappear … how do i get access to the touched instance? my code is as follows… I keep getting an error ‘attempt to index field ‘sprite’’

[code]
require(“sprite”);

local data = require(“uma”).getSpriteSheetData();
local sheet = sprite.newSpriteSheetFromData(“uma.png”, data)
local set = sprite.newSpriteSet(sheet, 1, 8)
local function spriteTouch(event)

if event.phase == “ended” then
event.sprite:removeEventListener(“touch”, spriteTouch)
event.sprite:removeSelf()
end

end

local function runhorsey(myEvent)
if myEvent.phase == “ended” then
local instance = sprite.newSprite(set)
instance.x = myEvent.x
instance.y=myEvent.y
instance:play()
instance:addEventListener(“touch”, spriteTouch)
end
end

Runtime:addEventListener(“touch”, runhorsey)

[/code] [import]uid: 67619 topic_id: 11748 reply_id: 311748[/import]

hey all…

I managed to work out how to get the touched instance… use event.target…

so now it works… the sprite is getting deleted… but there is another issue… because i am touching the screen to delete… it deletes the sprite… but then recreates it because of the runtime listener… how can I avoid the runtime listener? so that it doesn’t fire on this event?

I tried removing the Runtime:removeEventListener(“touch”, runhorsey) in the spriteTouch event but still the same issue

Thanks
[import]uid: 67619 topic_id: 11748 reply_id: 42810[/import]