|
From: adam on 16 Apr 2008 09:56 Recently I have discovered that I need to remove all instances of the keyframePlayer modifier in a stopMovie function, or else when my projector is closed an error message appears. An on stopMovie handler is a good place to put Lingo that performs cleanup tasks--such as closing resource files, clearing global variables, erasing fields, and disposing of objects--when the movie is finished. I come from a Flash background, and am just now starting to learn about how memory is handled. Do I need to delete objects and clear variables in the stopMovie function as well? Is there a rule of thumb to follow? I am not getting an error when I close the projector now? am I safe?
From: Chunick on 16 Apr 2008 15:08 you can use either: clearGlobals() or _global.clearGlobals() or for Javascript only (undocumented) _system.gc() depending on the version of Director. That will clear all global variables. Other than that, you should kill all objects such as script created members, Xtras and timeOut objects. to kill an individual global variable: global gSomeVar .. ... gSomeVar = VOID ie. mem = new(#bitmap) or mem = _movie.newMember(#bitmap) .. ... mem.erase() fileObj = xtra("FileIO").new() or fileObj = new(xtra "FileIO") .. ... fileObj = 0 timeOut("timeout object").new(1000, #someTimeoutHandler, me) or timeOut().new("timeout object", 1000, #someTimeoutHandler, me) .. ... timeOut("timeout object").forget() all these objects can be killed where they were created locally and unless you're using global variables, don't need to be killed in the on stopMovie handler... the clearGlobals() is a catchall that will do the trick. further reading: clearAsObjects() clearCache unload() unloadMember() unloadMovie()
From: adam on 16 Apr 2008 15:15 Thanks for your response; this is exactly what I was looking for.
|
Pages: 1 Prev: Director Mile High Table and D11 Xtras List Next: scripting window cursor issues |