Audio handles, dispose and reuse handle?

Hey guys,
so this should be an easy question to answer for you seasoned corona experts. I am working on a story book, so in my code I have an audio handle.

local narrativeAudio  
  
narrativeAudio = audio.loadSound("nar"..global.thisStoryNumber.."p"..global.thisPageNumber..".mp3")  

So with each new page that loads I want to dispose the current audio that is associated with the “narrativeAudio” handle. According to the documentation I also want to set my audio handle to Nil. This is fine but does that mean I have to create a new variable to be a new audio handle each time a page is changed? I would like to be able to use “narrativeAudio” only. Is there a way to unload and dispose of audio properly while then reusing the same audio handle for my next sound file?

Or perhaps im going about this the wrong way, any thoughts would be appreciated. [import]uid: 19620 topic_id: 25896 reply_id: 325896[/import]

Once you dispose of the audio handle, you are free to reuse the variable name.

The suggestion to assign to nil is to let the Lua garbage collector know it can collect Lua memory associated with the variable and also protect users from accidentally using the variable after it has been disposed (which can cause crashes.) The Lua garbage collector understands that the two are the same thing:

-- after you have called: audio.dispose(narrativeAudio)  
narrativeAudio = nil  
narrativeAudio = audio.loadSound("nar"..global.thisStoryNumber.."p"..global.thisPageNumber..".mp3")  
-- after you have called: audio.dispose(narrativeAudio)  
narrativeAudio = audio.loadSound("nar"..global.thisStoryNumber.."p"..global.thisPageNumber..".mp3")  

[import]uid: 7563 topic_id: 25896 reply_id: 104781[/import]

Ok so in my case i will be ok to use only audio.dispose, and then i can re use the variable name? So I won’t want to set the variable to nil because that is what can cause crashes correct? I’ll give it a try when i get home later… after work =( [import]uid: 19620 topic_id: 25896 reply_id: 104910[/import]