http://www.birchlabs.co.uk/Invasion-5.swf

On the 'buy' screen, there are 6 unit buttons with which you can buy troops. You can control these by clicking and holding.

Clicking 'play' to go into a battle has 6 identical buttons used for deploying the troops you bought. These _should_ be able to be held down, but there is a problem. It seems that they erroneously call a 'MOUSE_OUT' event even if your mouse is not moving.

The pattern dictating which battle buttons can be held and which can't is as follows: any buttons you clicked on the 'buy' screen will get bugged on the battle screen.

But I don't get this. They're not the same buttons. I quite thoroughly remove them before going to the 'battle' screen (though I'm not convinced this actually means they're gone):

Code:
beginMatchButton.addEventListener('menuButtonClicked', function(e:Event):void {
	for (i = 0; i < buttons.length; i++) {
		buttons[i].removeEventListener("buyTroop", buyTroop);
		buttons[i].removeEventListener("movehighlight", moveHighlight);
		buttons[i].removeEventListener("dimhighlight", dimHighlight);
		buttons[i].active = false;
		removeChild(buttons[i]);
	}
	buttons = [];
	clearScreen();
	begin('battle');
})
By setting them to active = false, the class removes all its mouse handling:

Code:
// Inside setter for 'active' variable:
useHandCursor = false;
buttonMode = false;
removeEventListener(MouseEvent.MOUSE_OVER, mouseOver);
removeEventListener(MouseEvent.MOUSE_OUT, mouseOut);
removeEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
removeEventListener(MouseEvent.MOUSE_UP, mouseUp);
removeEventListener(Event.ENTER_FRAME, purchase);

__active = false;
So I can't see how these buttons could interfere with the mouse events of their successors.

The buttons defined on the menu are made in pretty much the same way as the ones on the battle screen:

Code:
// Menu:
counts = [100,100, 100, 100, 20, 20];
costs = [100, 200, 300, 400, 500, 200];
buttons = [];
textClouds = [];
costClouds = [];

buttons.push(new UnitButton(infUp, infDown, buyTroop, 0, gold >= costs[0], 080, 160));
buttons.push(new UnitButton(arcUp, arcDown, buyTroop, 1, gold >= costs[1], 116, 160));
buttons.push(new UnitButton(palUp, palDown, buyTroop, 2, gold >= costs[2], 152, 160));
buttons.push(new UnitButton(canUp, canDown, buyTroop, 3, gold >= costs[3], 188, 160));
buttons.push(new UnitButton(ramUp, ramDown, buyTroop, 4, gold >= costs[4], 224, 160));
buttons.push(new UnitButton(sabUp, sabDown, buyTroop, 5, gold >= costs[5], 260, 160));

addChild(auraSprite);
for (i = 0; i < buttons.length; i++) {
	buttons[i].addEventListener("buyTroop", buyTroop);
	buttons[i].addEventListener("movehighlight", moveHighlight);
	buttons[i].addEventListener("dimhighlight", dimHighlight);
	addChild(buttons[i]);
	textClouds.push(new TextCloud(42 + 36 * i, 188, "123", 0xFFFFFF));
	costClouds.push(new TextCloud(42 + 36 * i, 142, "123", 0xFAEC18));
	addChild(textClouds[i]);
	addChild(costClouds[i]);
	textClouds[i].text = counts[i];
	costClouds[i].text = costs[i];
}
Code:
// Battle:
buttons = [];
textClouds = [];

buttons.push(new UnitButton(infUp, infDown, createTroop, 0, counts[0] > 0, 080, 364));
buttons.push(new UnitButton(arcUp, arcDown, createTroop, 1, counts[1] > 0, 116, 364));
buttons.push(new UnitButton(palUp, palDown, createTroop, 2, counts[2] > 0, 152, 364));
buttons.push(new UnitButton(canUp, canDown, createTroop, 3, counts[3] > 0, 188, 364));
buttons.push(new UnitButton(ramUp, ramDown, createTroop, 4, counts[4] > 0, 224, 364));
buttons.push(new UnitButton(sabUp, sabDown, createTroop, 5, counts[5] > 0, 260, 364));

addChild(auraSprite);
for (i = 0; i < buttons.length; i++) {
	buttons[i].addEventListener("buyTroop", createTroop);
	buttons[i].addEventListener("movehighlight", moveHighlight);
	buttons[i].addEventListener("dimhighlight", dimHighlight);
	addChild(buttons[i]);
	textClouds.push(new TextCloud(42 + 36 * i, 346, "123", 0xFFFFFF));
	addChild(textClouds[i]);
	textClouds[i].text = counts[i];
}
Only difference is the function they call when clicked, and the condition for them to grey themselves out.

I have confirmed that there are no errors in the way I declared the 'battle' buttons; if I never make the 'menu' buttons, the 'battle' buttons work just fine. Thus, it is definitely the existence of the 'menu' buttons which is interfering with the function of the 'battle' buttons.

I've tried everything I can think of. For hours... I'm seriously out of ideas. If anyone can suggest why clicking on one of the 'menu' buttons breaks the mouse handling of the next one I make for the 'battle' screen, please tell me.