all groups > flash actionscript > june 2005 >
You're in the

flash actionscript

group:

How do you reset a XML document?


How do you reset a XML document? ManinBlaq
6/9/2005 11:50:18 PM
flash actionscript:
When the Flash App initializes, it loads it's settings from an XML document.
Periodically, it needs to reload for newer information ...

Before reloading new information, I'm trying to purge the current XML object.
I'm calling docroot_xml.removeNode(); but it has no affect on the object.

Is there a better way to do this? Calling 'load' on the document, seems to
work well enough -- it's just my preference / style, to purge the old data.

I would like to know why this isn't working though.
Re: How do you reset a XML document? Rothrock
6/10/2005 12:00:00 AM
ManinBlaq ? Also I'm thinking that docroot_xml is your XML object, right? I
don't think you can removeNode it since it isn't a node, it is an XML object. I
think you would need to docroot_xml.firstChild.removeNode(). Or something like
that.

phildouglas ? Is there really a benefit to deleting the XML object? It seems
if you know you will be reusing it that it would make sense to just delete the
loaded data but reuse the events and all that stuff you set up. Can you explain
it a bit more? I'm fairly new to this, so I would just like to understand.
Re: How do you reset a XML document? phildouglas
6/10/2005 12:00:00 AM
Well you can use either method. i suppose you are right about having to
reconstruct the xml with all its events, however your constructor function will
also contain these events to set them up in the first place, so you will in a
sense have duplicates of any functions sitting in your memory.

It depends on the circumstances whether this is a hinderence or not. It
basically comes down to memory usage (having xml with functions in memory as
well as duplicates in the constructor function) vs processor usage (setting up
the xml and fuctions every time you need it).

if you're refreshing the data in the XML frequently then the first case is
probably more suitable, however if you only need to use this every few minutes
then its probably best not to have it hanging around in the memory.

Mind you these are both extreme circumstances before it affects performance
(i.e. very frequent xml loads or massive xml loads and functions) so in most
cases you can probably pick either method and see no negative effects.

It just seemed for the description given of what was needed that the XML would
be refreshed pretty infrequently, so it doesnt really need to stick around.
Re: How do you reset a XML document? Rothrock
6/10/2005 12:00:00 AM
Re: How do you reset a XML document? abeall
6/10/2005 12:00:00 AM
Re: How do you reset a XML document? ManinBlaq
6/10/2005 12:00:00 AM
Thank you very much ..this is exactly what I was looking for.

Rothrock, you are correct ..I was attempting to removeNode on my XML object ..
and obviously it was not working. Thank you for your input as well.
Re: How do you reset a XML document? phildouglas
6/10/2005 1:28:31 AM
just create a new xml with the same name and it will overwrite.

myXML = new XML()
// xml stuff here then wipe it with:
myXML = new XML()
AddThis Social Bookmark Button