ERROR: nil key supplied for property lookup.

function spriteListener(event) if event.phase == "next" then end if event.target.sequence=="boom" then if( event.phase == "ended" ) then event.target:removeEventListener( "sprite" ) event.target:setSequence("fire") event.target:play() end end return true end mysprite=gui\_t.new\_sprite(0, 0, 0.8, 0.8) --create sprite mysprite:setSequence("fireworks") mysprite:play() mysprite:addEventListener( "sprite", spriteListener) group:insert(safe\_new.guide\_safe\_sprite) 

–if i comment out this line : event.target:removeEventListener( “sprite” )
–i dont get the error anymore, but setSequence will not happen

What is gui_t? 

If you are attempting to use the Corona SDK sprite library, we have deprecated it in favor of display.newSprite().  See:  http://docs.coronalabs.com/api/library/display/newSprite.html

While we have open sourced our old sprite library, we no longer provide support on it.  If you’re using some other 3rd party solution (which it looks like you might be), then see the library creator for support.  I would highly recommend updating to our current sprite library if you can.

Rob

Hi Rob, thank you for sharing the library, yeah that’s the one i follow when creating my sprite, here is my code:
 

function gui.new\_sprite(x, y, xScale, yScale) -- 1st image sheet local sheetData1 = { width=202, height=202, numFrames=49, sheetContentWidth=2022, sheetContentHeight=1012 } local sheet1 = graphics.newImageSheet( "fireworksanimation.png", sheetData1 ) -- 2nd image sheet local sheetData2 = { width=202, height=202, numFrames=49, sheetContentWidth=2022, sheetContentHeight=1012 } local sheet2 = graphics.newImageSheet( "fireblowfireworks.png", sheetData2 ) -- In your sequences, add the parameter 'sheet=', referencing which image sheet the sequence should use local sequenceData = { {name = "fireworks", sheet=sheet1, frames={1}, time = 10000,loopCount = 1}, {name = "fire", sheet=sheet1, frames={2,3,4,5,6,7,8,9,10,11,12}, time = 2800,loopCount = 1}, { name="blow", sheet=sheet1, start=13, count=49, time=3000, loopCount=1 }, { name="smoke", sheet=sheet2, start=13, count=49, time=6000, loopCount=1 } } local sprite = display.newSprite( sheet1, sequenceData ) sprite.x = x sprite.y = y sprite.xScale=xScale sprite.yScale=yScale --sprite:play() return sprite end

local gui_t=require(“gui”)

Try:   event.target:removeEventListener( “sprite”, spriteListener )

They have to be an exact match and of course the function part (spriteListener) has to be the same function pointer used in the addEventListener calls, which is why you can’t use anonymous functions for this.

Rob

Thank you Rob :slight_smile:
Another issue i am struggling is the code works fine first time i call it, but not the second.

Can’t understand the reason why?

Any error messages in your console log that might be of use?  I’m not a fan of loading the graphics sheet multiple times.  You can load it once and just keep building sprites off of it.

We will probably need to see more code or have a better idea about what’s not working.  When you say “its not working”, doesn’t give much to go on.

Rob

What is gui_t? 

If you are attempting to use the Corona SDK sprite library, we have deprecated it in favor of display.newSprite().  See:  http://docs.coronalabs.com/api/library/display/newSprite.html

While we have open sourced our old sprite library, we no longer provide support on it.  If you’re using some other 3rd party solution (which it looks like you might be), then see the library creator for support.  I would highly recommend updating to our current sprite library if you can.

Rob

Hi Rob, thank you for sharing the library, yeah that’s the one i follow when creating my sprite, here is my code:
 

function gui.new\_sprite(x, y, xScale, yScale) -- 1st image sheet local sheetData1 = { width=202, height=202, numFrames=49, sheetContentWidth=2022, sheetContentHeight=1012 } local sheet1 = graphics.newImageSheet( "fireworksanimation.png", sheetData1 ) -- 2nd image sheet local sheetData2 = { width=202, height=202, numFrames=49, sheetContentWidth=2022, sheetContentHeight=1012 } local sheet2 = graphics.newImageSheet( "fireblowfireworks.png", sheetData2 ) -- In your sequences, add the parameter 'sheet=', referencing which image sheet the sequence should use local sequenceData = { {name = "fireworks", sheet=sheet1, frames={1}, time = 10000,loopCount = 1}, {name = "fire", sheet=sheet1, frames={2,3,4,5,6,7,8,9,10,11,12}, time = 2800,loopCount = 1}, { name="blow", sheet=sheet1, start=13, count=49, time=3000, loopCount=1 }, { name="smoke", sheet=sheet2, start=13, count=49, time=6000, loopCount=1 } } local sprite = display.newSprite( sheet1, sequenceData ) sprite.x = x sprite.y = y sprite.xScale=xScale sprite.yScale=yScale --sprite:play() return sprite end

local gui_t=require(“gui”)

Try:   event.target:removeEventListener( “sprite”, spriteListener )

They have to be an exact match and of course the function part (spriteListener) has to be the same function pointer used in the addEventListener calls, which is why you can’t use anonymous functions for this.

Rob

Thank you Rob :slight_smile:
Another issue i am struggling is the code works fine first time i call it, but not the second.

Can’t understand the reason why?

Any error messages in your console log that might be of use?  I’m not a fan of loading the graphics sheet multiple times.  You can load it once and just keep building sprites off of it.

We will probably need to see more code or have a better idea about what’s not working.  When you say “its not working”, doesn’t give much to go on.

Rob