storyboard and unloading a scene

FIRST…I know storyboard is being replaced, but I have 20000 lines of code in this project and I’m not on a timetable to re-write it using composer.

Second… I’m using the following code to load scenes so that I have a smooth iOS7 style transition…

 globals.documentToShow = "http://www.lvhn.org" globals.title = "LVHN.ORG" globals.documentExt = "" globals.documentPath = "" globals.returnScene = "scene\_menu" storyboard.loadScene( "scene\_viewer", false, options ) storyboard.gotoScene ( "scene\_viewer", { effect="iosSlideLeft", time=globals.transTime } ) 

It can be called multiple times on the same screen to load multiple documents.  The first time, all works as it should.  I’m setting global variables to tell the scene what to load (it’s a basic HTML viewer to view local documents and web sites).

I’m assuming that it keeps a copy of the scene in memory until I exit the scene and just keeps displaying it.  Is there a way to force it to reload?  I need it to take the parameters and use them each time instead of displaying whatever the user chose the first time.

Thanks!

you need to get a handle on storyboard’s purge and remove concepts.

purge meaning (roughly):  destroy the display objects BUT retain the Lua code

remove meaning (roughly):  destroy the display objects AND unload the Lua code

and, by default, NEITHER occurs automatically.  (except under extraordinary low-memory conditions)

If you have a scene that is frequently revisited, then you might actually WANT the default behavior, as it’ll save you from recreating all those display objects over and over again on each visit.  But what you’d want is to restructure the scene a bit so that it can “refresh” (not recreate) its contents on each load, perhaps in the willEnterScene event (which occurs prior to any transition, so your new content would be visible during transition), or in enterScene (whcih occurs post-transition).

otoh, if you really do want to blow away the whole scene, display objects and code, then investigate storyboard.removeScene().  tho note that you need to call this AFTER the intended scene is no longer active (you can’t unload Lua code that is still actively referenced by storyboard) and you HAVE to make sure you’ve properly destroyed and released all scene contents (no dangling references) or Lua will (again) refuse to unload the code (because its still actively referenced by something of yours).

btw, composer operates the same way, though names of things have changed.

you need to get a handle on storyboard’s purge and remove concepts.

purge meaning (roughly):  destroy the display objects BUT retain the Lua code

remove meaning (roughly):  destroy the display objects AND unload the Lua code

and, by default, NEITHER occurs automatically.  (except under extraordinary low-memory conditions)

If you have a scene that is frequently revisited, then you might actually WANT the default behavior, as it’ll save you from recreating all those display objects over and over again on each visit.  But what you’d want is to restructure the scene a bit so that it can “refresh” (not recreate) its contents on each load, perhaps in the willEnterScene event (which occurs prior to any transition, so your new content would be visible during transition), or in enterScene (whcih occurs post-transition).

otoh, if you really do want to blow away the whole scene, display objects and code, then investigate storyboard.removeScene().  tho note that you need to call this AFTER the intended scene is no longer active (you can’t unload Lua code that is still actively referenced by storyboard) and you HAVE to make sure you’ve properly destroyed and released all scene contents (no dangling references) or Lua will (again) refuse to unload the code (because its still actively referenced by something of yours).

btw, composer operates the same way, though names of things have changed.