Thanks Tracy, But complex objects are passed by reference. Right after the assignment in the function, the address of the variable is modified, i.e. += actually creates a new variable... - Breizo
Tracy Spratt-2 wrote: > > Hmm, it is acting like the XMLList variable is being passed as a value and > not a reference. > I can think of at least three other ways to do this. > Tracy Spratt, > From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On > Behalf Of Breizo > Sent: Friday, September 25, 2009 10:00 AM > To: flexcoders@yahoogroups.com > Subject: [flexcoders] XMLLIst += operator problem > Hi, > Trying to do a simple element add to a XMLList but running into basic > problems. > Has anyone already fixed this? > > When I run the example, I get: > <node1/> > <node1/> > <node2/> > <node1/> > > when I would expect > <node1/> > <node1/> > <node2/> > <node1/> > <node2/> > > Any idea? > > Thanks > > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe. > <http://www.adobe.com/2006/mxml> > com/2006/mxml" layout="absolute" > applicationComplete="init();"> > <mx:Script><![CDATA[ > private function init():void{ > var xmll:XMLList = new XMLList(); > xmll+=<node1/>; > trace(xmll.toXMLString()); > addX(xmll); > trace(xmll.toXMLString()); > } > private function addX(x:XMLList):void{ > x+=<node2/>; > trace(x.toXMLString()); > } > ]]></mx:Script> > </mx:Application> > -- > View this message in context: http://www.nabble. > <http://www.nabble.com/XMLLIst-%2B%3D-operator-problem-tp25577790p25577790.h > tml> com/XMLLIst-%2B%3D-operator-problem-tp25577790p25577790.html > Sent from the FlexCoders mailing list archive at Nabble.com. > > > > > -- View this message in context: http://www.nabble.com/XMLLIst-%2B%3D-operator-problem-tp25577790p25629633.html Sent from the FlexCoders mailing list archive at Nabble.com.