Isn't it because the XMLList has references to the original nodes and
not copies?

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of flexaustin
Sent: Tuesday, August 19, 2008 11:02 PM
To: [email protected]
Subject: [flexcoders] Normalize removing my data??? Is this a bug in
Flex?

 

I have been tracing this bug for two days and finally found it. I
don't see how this .normalize method is changing data in other areas
of my code?

So when makeData is called I pass it xml with child nodes. It is
stored in _data and then I se several variables and call the the
buildXMLObj method. When inside the buildXMLObj when the line with
.normalize is run my variable _data (now only contains parent nodes
with out the children). The buildXMLObj removes children but it is
never assigned to _data so how is _data getting changed?

package 
{
public class DataDelegate
{
import mx.rpc.AsyncToken;
import mx.utils.ObjectUtil;

import com.models.ViewModelLocator;

private var modelLocator:ViewModelLocator =
ViewModelLocator.getInstance();
private var _newSelected:int = 0;
private var midXML:XMLList;
private var _data:XMLList;

public function DataDelegate(){

}

private function buildXMLObj(xmllist:XMLList):void
{
var copyOfList:XML = <groups/>;
for each (var xl:XML in xmllist)
{
if (xl.length())
{
xl.replace("*", "");
}
copyOfList.appendChild(xl);
}
copyOfList = copyOfList.normalize();
midXML = copyOfList.descendants("*");

}

public function makeData(datas:XML):void
{
trace("MakeData was called
---------------------------------------------------");
var _data:XML = datas;
modelLocator.selected = -1;
var xml:XML = datas as XML;
var _newSelected:int;

var comps:XMLList = xml.group.component;
buildXMLObj(xml.group);
var groups:XMLList = midXML;

if (modelLocator.comps.length() > 0)
{ 
_newSelected = parseInt([EMAIL PROTECTED]);
modelLocator.selected = _newSelected;
}
/* modelLocator.allDataArr.splice(_newSelected,1); */
modelLocator.allDataArr[_newSelected] = _data; 
modelLocator.comps = comps;
modelLocator.groups = groups;
}
}
}

 

Reply via email to