Why is it so hard to click my movieclip?
I have a movie clip (tempEnemyA) in an array (enemiesA). These enemies fall down and the player kills them by clicking on them. The higher the score = the faster the enemies drop. For some reason though, when there are a lot of enemies on stage, they start to become very hard to click. This is the code inside the tempEnemyA:
import flash.events.MouseEvent;
import flash.display.MovieClip;
import fl.motion.Animator;
import flash.events.*;
import flash.utils.setTimeout;
this.addEventListener(MouseEvent.CLICK, killM);
this.dead3 = false;
function killM(event:MouseEvent😞void
{
this.dead3=true;
this.mouseChildren=false
gotoAndPlay(31);
this.removeEventListener(MouseEvent.CLICK, killM);
flash.utils.setTimeout(removeSelfM,2000);
}
function removeSelfM():void
{
this.parent.removeChild(this);
this.addEventListener(MouseEvent.CLICK, killM);
}
this.dead3 activates this condition inside the stage layer:
if (tempEnemyA.dead3)
{
scoreA++;
scoreA++;
AntLevel.scoreA_txt.text = String(scoreA);
enemiesA.splice(g,1);
}
As a whole this is the whole code that spawns the enemies:
function makeEnemiesA():void
{
var chance:Number = Math.floor(Math.random() * 150);
if (chance <= + levelA)
{
//Make sure a Library item linkage is set to Enemy...
tempEnemyA = new Mosquito();
tempEnemyA.speed = 2
//Math.random(); gets a random number from 0.0-1.0
tempEnemyA.x = Math.round(Math.random() * 550);
addChild(tempEnemyA);
enemiesA.push(tempEnemyA);
tempEnemyA.speed = enemyBaseSpeed3 + ((levelA - 1) * speedLevelInc3);
if (tempEnemyA.speed > MAX_SPEED3)
{
tempEnemyA.speed = MAX_SPEED3;
}
}
}
function moveEnemiesA():void
{
var tempEnemyA:MovieClip;
for (var g:int =enemiesA.length-1; g>=0; g--)
{
tempEnemyA=enemiesA[g];
if (tempEnemyA.dead3)
{
scoreA++;
scoreA++;
AntLevel.scoreA_txt.text = String(scoreA);
enemiesA.splice(g,1);
}
else // Enemy is still alive and moving across the screen
{
//rotate the enemy between 10-5 degrees
tempEnemyA.rotation += (Math.round(Math.random()*.4));
//Find the rotation and move the x position that direction
tempEnemyA.x -= (Math.sin((Math.PI/180)*tempEnemyA.rotation))*tempEnemyA.speed;
tempEnemyA.y += (Math.cos((Math.PI/180)*tempEnemyA.rotation))*tempEnemyA.speed;
if (tempEnemyA.x < 12)
{
tempEnemyA.x = 12;
}
if (tempEnemyA.x > stage.stageWidth - offset2)
{
tempEnemyA.x = stage.stageWidth - offset2;
}
if (tempEnemyA.y > stage.stageHeight)
{
removeEnemyA(g);
livesA--;
AntLevel.livesA_txt.text = String(livesA);
}
}
}
}
