On 28/06/2010 17:19, Lehr, Theodore wrote:
First - let me say that this code may be totally screwed up... that is a
possibility!
Try:
while ( parent.parent.numChildren 1){
if (parent.parent.getChildAt(0).name != navName) {
parent.parent.removeChildAt(0);
} else {
parent.parent.removeChildAt(1);
}
}
What I am trying to do is remove child mcs and load a new one. My code is:
function onCompleteHandler(e:Event)
{
var pChildren:int = new int(parent.parent.numChildren);
parent.parent.addChild(e.currentTarget.content);
var foundMC:int=0;
for (var j:int=0; jpChildren; j++)
{
if (foundNav==0)
{
if (parent.parent.getChildAt(0).name != navName) {
parent.parent.removeChildAt(0);
} else {
foundNav = 1;
}
} else {
parent.parent.removeChildAt(1);
}
}
if (foundNav==1) {
parent.parent.removeChildAt(0);
}
}
}
The intent of this to remove all of the mcs on the stage (except for the one
that is added at the beginning of the function - making sure that the last one
removed (navName) is the one that is firing this code
Doing some tracing, I am seeing that it is failing like half way through the removal -
say if I have 8 mcs on the stage at the beginning - it goes up to 9 when I add the new
one then about half way through - at this line: parent.parent.removeChildAt(0); I am
getting Error #2006: The supplied index is out of bounds I would think there
would be a child at 0 if there were still children in existence...
any thoughts?
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders