is there a sample of how to implement code on exit?

Hi,

I need to delete a couple of temporary files if the app is exited.
the deletion part i can handle but how do i trigger it on exit?

thanks,

Rob [import]uid: 2131 topic_id: 389 reply_id: 300389[/import]

register a system event and look for

“applicationExit”

Additional information in page 54 of the APIReference

Carlos [import]uid: 24 topic_id: 389 reply_id: 706[/import]

thanks,

I tried that but couldn’t get it to work,
I have managed to get round it this time, i’ll have another go when i need it next,

thanks again,

Rob [import]uid: 2131 topic_id: 389 reply_id: 707[/import]

Couldn’t get it to work? could you send me some code to test?

C [import]uid: 24 topic_id: 389 reply_id: 708[/import]

I suspect it’s a me problem (it usually is) rather than something your end,

local function onSystemEvent( event )
if event.type == “applicationExit”
then
– save stuff to disk
os.remove( filePath )
os.remove( tagePath )
else
end
end
Runtime:addEventListener( “enterFrame”, onSystemEvent );

thanks,
Rob [import]uid: 2131 topic_id: 389 reply_id: 709[/import]

Shouldn’t it be:

Runtime:addEventListener ( “system”, onSystemEvent );

instead ? I might be wrong but that’s what I understand of the API reference. :wink: [import]uid: 1058 topic_id: 389 reply_id: 711[/import]

happylewie is right.

it should be Runtime:addEventListener ( “system”, onSystemEvent );

c [import]uid: 24 topic_id: 389 reply_id: 712[/import]

Thanks pair,
i knew it would be a me problem!! [import]uid: 2131 topic_id: 389 reply_id: 713[/import]