Help with Sprites

I am using a sprite as a container so that when the users chooses a new item from a combobox, the sprites contained in the container sprite can be removed but for some reason it keeps displaying this error:
“RangeError: Error #2006: The supplied index is out of bounds.”

Here is the sprite I create outside of all functions and some global variables:


var container:Sprite=new Sprite(); 
this.addChild(container);
var numCircles:int = 0;
var compareValue:int = 0;
var VxNum:Number = -89;

Then I have a function that creates circles based on what is read from an xml file (which is what avgData contains) and adds them to the sprite container:



var yNum:Number = 104;
var i:int;

for(i=0; i<avgData.length; i++)
{
var circle:Sprite = new Sprite();
numCircles+=1;

circle.graphics.lineStyle(1, 0x000000, 1);
circle.graphics.beginFill(0x003366,1);


if(compareValue==0)
{
    circle.graphics.drawCircle(150, 150, (avgData*[2]*5.25));
}
else
{
    circle.graphics.drawCircle(150, 150, (avgData*[3]*2));
}

circle.graphics.endFill();
circle.x = VxNum;
circle.y = yNum;
circle.alpha = .5;

container.addChildAt(circle, container.numChildren);

VxNum = VxNum + 20;
}

then finally I have a function that is called if a combobox’s value is changed which will remove all the graphics and children inside the container:


function getItem(event:Event):void
{
    var i:int;
    for(i=0;i<numCircles;i++)
    {
        
        Sprite(container.getChildAt(i)).graphics.clear();
        
        Sprite(container.getChildAt(i)).removeChildAt(0); 
        
    }
    
    while(container.numChildren>0)
    {
        container.removeChildAt(0);
    }
    
    numCircles=0;
}

However, I keep getting that error:
“RangeError: Error #2006: The supplied index is out of bounds.”
when it reaches this line:
Sprite(container.getChildAt(i)).removeChildAt(0);

Can anybody tell me why?

I’d greatly appreciate it,
lOzts