PDA

View Full Version : Deleteing XML objects


fleeklee
07-28-2003, 04:11 PM
I'm not sure when it is approriate to delete objects. Many of the examples I've seen do not delete an XML object after its been created. I was under the impression you should have a corresponding "delete" for every "new".

If you have to delete the object then how would it be appropriately deleted in the following code?

xmlObject = new XML();
xmlObject.onLoad = function(success) {
if (success)
trace(this);
delete this; //???
}

Will this work? Can you delete an object as a direct result of an event handler?

Thanks,
Ken

fgf
07-28-2003, 04:53 PM
delete should work.

Not really worth the bother tho unless your makeing xml objects inside a loop or your xml object is book sized. They'll get dumped when the users leaves the page/movie.

Flashs garbage collection is pretty bad but check out removeMovie clip ad well if you want to be conscientous.

fgf

fleeklee
07-28-2003, 05:11 PM
Thanks,

This is a stanalone app that needs to run continuously all day and it will be processing lots of xml data.

It would be nice if there were best practices for long running flash apps.

fgf
07-28-2003, 05:17 PM
That would be a good case for being tidy.

Remove Movie clip tidies up memory (according to a mooke article) as well as removing dynamically created clips.

fgf

fleeklee
07-29-2003, 06:41 PM
I just saw some code that deleted an anonymous function. Is this something to be concerned about?

function create() {
button.onPress = function() {... }
}

function destory() {
delete button.onPress;
}