Hey all,
I have an interesting (and frustrating) problem. I have made this actionscript, that generates movieclips according to data extracted from an XML file. I would like to remove all these movieclip when moving on to another frame. The interesting thing is, I use the same code for both the generating as well as the removal of these clips, except for the "removeMovieClip" Syntax instead of the "duplicateMovieClip"
The duplication works perfectly and I get all my points plotted, however when I try to remove them sor some reason I get only half of my clips removed as if I had the k++ in my loop twice.
On a closer look I found that it simply can't find every second movieclip that it searches for. Specifically if you look down in the remove clip function, the following " if (dataset[k].nodeName == "set") " returns NULL for every other value...
Hope someone uderstands this... I am freaking out...
XMLDoc = new XML();
XMLDoc.ignoreWhite = true;
xmldocurl = _root.dataurl;
if (xmldocurl.length<1) {
xmldocurl = "Data.xml";
}
XMLDoc.load(xmldocurl);
XMLDoc.onLoad=function(){
var i=0
cldnodes = new Array();
cldnodes = XMLDoc.childNodes;
for (j=0; j<=cldnodes.length; j++) {
if (cldnodes[j].nodeName.toUpperCase() == "GRAPH") {
dataset = cldnodes[j].childNodes;
for (k=0; k<=dataset.length; k++) {
if (dataset[k].nodeName == "set") {
arg=dataset[k].attributes.name
//strtext="<B>" + dataset[k].attributes.name + " :</B><BR>" + dataset[k].attributes.count + " deals from $" + dataset[k].attributes.from
//setProperty ( arg, _visible, true);
//EventHandler(arg, strtext);
duplicateMovieClip (_root.mainmovie, arg, dataset[k].attributes.level);
trace(k+" "+arg+" "+_root[arg].getDepth());
// p=project(dataset[k].attributes.x,dataset[k].attributes.y)
// px=p.x
// py=p.y
// setProperty (arg, _x, 425);
// setProperty (arg, _y, 270);
setProperty (arg, _x, projectx(dataset[k].attributes.y,dataset[k].attributes.x));
setProperty (arg, _y, projecty(dataset[k].attributes.y,dataset[k].attributes.x));
setProperty(arg,_visible,true);
}
}
}
}
}
REMOVING THE CLIPS:
on (release) {
trace (k)
XMLDoc = new XML();
// XMLDoc.ignoreWhite = true;
xmldocurl = _root.dataurl;
if (xmldocurl.length<1) {
xmldocurl = "Data.xml";
}
var arg
var d
XMLDoc.load(xmldocurl);
XMLDoc.onLoad=function(){
cldnodes = new Array();
cldnodes = XMLDoc.childNodes;
for (j=0; j<=cldnodes.length; j++) {
if (cldnodes[j].nodeName.toUpperCase() == "GRAPH") {
dataset = cldnodes[j].childNodes;
for (k=0; k<=dataset.length; k++) {
if (dataset[k].nodeName == "set") {
arg=dataset[k].attributes.name
trace(_root[arg].getDepth());
_root[arg].removeMovieClip();
}
}
}
}
}