Hey all.
I have a problem with replacing values in an array.
[SIZE=2]I have this code that takes the string values out of an XML file:[/SIZE]
[SIZE=2]
**[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]public[/COLOR][/SIZE][/COLOR][/SIZE]****[SIZE=2][COLOR=#339966][SIZE=2][COLOR=#339966]function[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2] loadXML(xml:Event):[/SIZE]**[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]void[/COLOR][/SIZE][/COLOR][/SIZE]**
[LEFT][SIZE=2]{ [/SIZE]
[SIZE=2]container = [/SIZE]**[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]new[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2] XML(xml.target.data);[/SIZE][/LEFT]
[LEFT]**[SIZE=2][COLOR=#6699cc][SIZE=2][COLOR=#6699cc]var[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2] aantalSommen:Number = container.somTotaal.length() -1;[/SIZE]
**[SIZE=2][COLOR=#6699cc][SIZE=2][COLOR=#6699cc]var[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2] randomSom:Number = Math.round(Math.random()*aantalSommen); [/SIZE][/LEFT]
[LEFT][SIZE=2]uitkomstGetal = container.somTotaal.uitkomst.text()[randomSom];[/SIZE]
**[SIZE=2][COLOR=#cc6666][SIZE=2][COLOR=#cc6666]trace[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2]([/SIZE]**[SIZE=2][COLOR=#990000][SIZE=2][COLOR=#990000]"Uitkomst getal: "[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2]+uitkomstGetal)[/SIZE][/LEFT]
[LEFT][SIZE=2]deSom = container.somTotaal.som.text()[randomSom];[/SIZE]
**[SIZE=2][COLOR=#cc6666][SIZE=2][COLOR=#cc6666]trace[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2]([/SIZE]**[SIZE=2][COLOR=#990000][SIZE=2][COLOR=#990000]"De som: "[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2]+deSom)[/SIZE][/LEFT]
[LEFT][SIZE=2]Ballen = container.somTotaal.andereGetallen.text()[randomSom] +[/SIZE]**[SIZE=2][COLOR=#990000][SIZE=2][COLOR=#990000]","[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2]+ container.somTotaal.uitkomst.text()[randomSom];[/SIZE]
**[SIZE=2][COLOR=#cc6666][SIZE=2][COLOR=#cc6666]trace[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2]([/SIZE]**[SIZE=2][COLOR=#990000][SIZE=2][COLOR=#990000]"Extra ballen: "[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2]+Ballen)[/SIZE][/LEFT]
[SIZE=2]getallenRij = Ballen.split([/SIZE]**[SIZE=2][COLOR=#990000][SIZE=2][COLOR=#990000]","[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2]);[/SIZE]
[SIZE=2]And then this code inside a function which adds a new child (tijdelijkeBal) for every string in the array:[/SIZE]
[SIZE=2]
**[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]for each[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2] ([/SIZE]**[SIZE=2][COLOR=#6699cc][SIZE=2][COLOR=#6699cc]var[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2] buttonArray:String [/SIZE]**[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]in[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2] getallenRij){[/SIZE]
[SIZE=2]tijdelijkeBal = [/SIZE]
[LEFT]**[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]new[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2] Getal((String)(buttonArray));[/SIZE][/LEFT]
[LEFT][SIZE=2]tijdelijkeBal.x = Math.random() * stage.stageWidth;[/SIZE][/LEFT]
[LEFT][SIZE=2]tijdelijkeBal.y = Math.random() * stage.stageHeight;[/SIZE][/LEFT]
[LEFT][SIZE=2]addChild(tijdelijkeBal);[/SIZE][/LEFT]
[LEFT][SIZE=2]tijdelijkeBal.mouseChildren = [/SIZE]**[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]false[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2];[/SIZE]
[SIZE=2]ballenRij.push(tijdelijkeBal);[/SIZE][/LEFT]
[SIZE=2]} [/SIZE]
[LEFT][SIZE=2]And I have this in my constructor function:[/SIZE][/LEFT]
[SIZE=2][SIZE=2]lader.addEventListener(Event.COMPLETE, loadXML);[/SIZE][/SIZE]
[SIZE=2][SIZE=2]lader.load([/SIZE]**[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]new[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2] URLRequest([/SIZE]**[SIZE=2][COLOR=#990000][SIZE=2][COLOR=#990000]"sommen/plus.xml"[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2]));[/SIZE]
[/SIZE]
So far so good. Every time I reload my application, it takes a random set of 5 strings from the XML and it adds the 5 children.
[LEFT][SIZE=2][SIZE=2]What I want to do is reload the XML so that the previous added childred are replaced with new ones when I execute another lader.load([SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]new[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] URLRequest([/SIZE][SIZE=2][COLOR=#990000][SIZE=2][COLOR=#990000]“sommen/plus.xml”[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]));[/SIZE][/SIZE][/SIZE][/LEFT]
[LEFT][SIZE=2]Right now it’s so that whenever I load a new URLRequest for the XML file it just adds new children and leaves the previous ones there.[/SIZE][/LEFT]
[LEFT][SIZE=2]I tried doing removeChild(tijdelijkeBal); but that just removes one child. I think the last one in the array in fact.[/SIZE][/LEFT]
[LEFT][SIZE=2][SIZE=2]I hope this made sense. Thanks.[/SIZE][/SIZE][/LEFT]
[/SIZE][/SIZE]