Hi,
should I be using removeEventListener for XML loaders?
So far when ever I use addEventListener I always try to make sure I code a removeEventListener if I no longer need it or the object is removed etc. As far as I can tell this is good practice for reducing system resource usage.
In my case I am just using my XML to store some variables, used in the instantiation of various objects, so I can adjust without re-compiling.
essentially like so:
private var xmlLoader:URLLoader = new URLLoader();
private var xmlData:XML = new XML()
private var rangeLimit:uint;
setParameters();
function setParameters():void
{
xmlLoader.load(new URLRequest("myXML.xml"));
xmlLoader.addEventListener(Event.COMPLETE, processXML);
}
function processXML(e:Event):void
{
xmlData = new XML(e.target.data);
rangeLimit = xmlData.rangeLimit;
// xmlLoader.removeEventListener(Event.COMPLETE, processXML);
}
certainly if I take out the comments I dont get any errors. But I can’t think of any examples I have seen where others have removed the even listner.
If any one can shed some light on this it would be much appreciated!
Thanks.