removing objects - crash

Hi Everyone,

For my first Corona project I’m trying to build a phonics support program that goes with the phonics program at the school where I work. I’m trying to be memory wise and removing objects from a scene when the director class is called. Everything is fine unless I try to remove the “begin” button. The student is asked to click on “begin” to get started, but if I use the code to remove that button the program quits. Here’s the function I use to remove items. Does anyone have any ideas? I tried to just move the button off screen, but that causes issues in the next scene.

[code]function changeScene(e)
if(e.phase == “ended”) then
audio.stop();
audio.dispose(beepsAudio);
beepsAudio=nil;
w_lc1:removeSelf()
o_lc1:removeSelf()
r_lc1:removeSelf()
d_lc1:removeSelf()
marvin:removeSelf()
marvinRight45:removeSelf()
marvinRight:removeSelf()
marvinLeft45:removeSelf()
marvinLeft:removeSelf()
earBtn:removeSelf()
cancelBtn:removeSelf()
beginBlink:removeSelf()
skipBtn.x = _W;
beginBtn.x = _W;

director:changeScene(e.target.scene);

end
[import]uid: 48122 topic_id: 8590 reply_id: 308590[/import]

If you’re using director class then you need to put all your display objects in a local group. At the very end of each scene, you need to call a clean up function and director class will do the cleaning for you.

[lua]-- director class ver. 1.2 modified by Jonathan Beebe

cleanUp = function

– cancel timer if you have any
– cancel transition if you have any in progress

– use this to test if the function is performing

print(“remove Everything”)

audio.stop();
audio.dispose(beepsAudio);
beepsAudio=nil;

end [import]uid: 12455 topic_id: 8590 reply_id: 30876[/import]

Hey Teex,

Thanks for the reply. I had messed up something else which caused the grouping stuff not to work, but after I saw the code you left me I discovered my mistake. I appreciate the help, the projects is already looking better because of it. [import]uid: 48122 topic_id: 8590 reply_id: 30894[/import]