I've got a clip that I'm drawing and adding to the stage, and when it's clicked, it adds two duplicates of itself as children. I want these children to be clickable, but the problem is that, if they are clicked, it registers the click as being for both the parent click and its children. So then instead of adding two new clips, it adds 4. I can solve this by adding mouseChildren = false to the movieClip, but then when I do that, the new clips are drawn from the center of the parent clip, instead of from the origin of the clip that was clicked. How do I resolve this? This is my code:
function clickCircle(e:MouseEvent):void {
var thisCircle = e.target;
for (var i=0; i<thisCircle.childCircles;i++){
trace('drawCircle' + i);
drawCircle(thisCircle);
}
}
function drawCircle(parentCircle){
//trace('draw circle' + childCircles);
var xPos;
var yPos;
if (circleCount == 0){
xPos = centerStageX;
yPos = centerStageY;
} else {
//xPos = parentCircle.x;
//yPos = parentCircle.y;
xPos = yPos = 0;
}
var newCircle:Shape = new Shape();
newCircle.graphics.beginFill(circleColor);
newCircle.graphics.drawCircle(0,0,cr); //x, y, radius
newCircle.graphics.endFill();
var circleClip:MovieClip = new MovieClip();
//circleClip.mouseChildren = false;
circleClip.childCircles = numCircles;
circleClip.x = xPos;
circleClip.y = yPos;
circleClip.addChild(newCircle);
circleClip.id = circleCount;
if (circleCount == 0){
addChild(circleClip);
} else {
parentCircle.addChild(circleClip);
}
circleArray.push(circleClip);
circleClip.addEventListener(MouseEvent.CLICK,clickCircle);
if (circleCount != 0){
moveCircle(parentCircle,circleClip,xPos,yPos);
}
circleCount++;
}