Currently, if you click the box you made, it will remove that one but instantly create another one. I want a click on the stage to create a box and a click on the box to remove that box - that is all.
import flash.display.MovieClip;
import flash.events.*;
public class testcatnab extends MovieClip
{
public static var boxCount:int = 0;
var box = new Box();
public function testcatnab()
{
stage.addEventListener(MouseEvent.CLICK, clickOnStage);
box.addEventListener(MouseEvent.CLICK, clickOnBox);
}
function clickOnStage(e:MouseEvent)
{
box.x = mouseX;
box.y = mouseY;
addChild(box);
boxCount++;
trace(boxCount);
}
function clickOnBox(e:MouseEvent)
{
boxCount--;
removeChild(box);
trace(boxCount);
}
}
EDIT - fixed it by making a separate background movieclip and using that as the clickable object