I have a grid of many 10x10 pixel squares separated only by a pixel line. When the user rolls over the sprite, it grows, animating to about 4 times its size--to around 40x40 pixels. The sprite stays large while the mouse is over the sprite, but if the user wants to rollover the neighboring sprite it is obscured by this sprite and its larger size.
Is it possible to shrink the size of the hit area so that even though the sprite grows in size the mouse can still access or trigger the neighboring sprites underneath--to the right, left, top, bottom? I thought about using Mouse_move, but wasn't sure if that would fire off too many events.
I read the following posts. However, my hitArea needs to be the same size or just slightly larger than the original 10x10 pixel sprite. I've had little success.
Not sure if this matters: I'm working with an ActionsScript class within a Flex project. The main class file is mxml.
Routing Mouse Events through a Sprite in Actionscript 3
public function onRollOver(event:MouseEvent):void
{
//do a bunch of stuff
timerUp.start();
timerUp.addEventListener(TimerEvent.TIMER, growSquare);
}
private function growSquare(e:TimerEvent):void
{
var maxSize:Number = 40;
if (currSprite.width < maxSize) {
currSprite.width++;
currSprite.height++;
if (currSprite.width > maxSize) {
currSprite.width = maxSize;
currSprite.height = maxSize;
}
e.updateAfterEvent();
} else {
timerUp.stop();
}
}
/////////Hit Area Code - From Square Object //////////////////
var vHeight:Number = 10;
var vWidth:Number = 10;
var square:Sprite = new Sprite();
square.graphics.beginFill(0x000000);
square.graphics.drawRect(0, 0, vWidth, vHeight);
square.graphics.drawRect(-vWidth/2, -vHeight/2, vWidth, vHeight);
square.graphics.endFill();
// try to decrease the hit area, or keep it at the original size
const hitArea:Sprite = new Sprite()
hitArea.graphics.beginFill( 0xFFFFFF );
hitArea.graphics.drawRect(-vWidth/2, -vHeight/2, vWidth, vHeight);
hitArea.mouseEnabled = false;
hitArea.visible = false;
hitArea.x = square.x
hitArea.y = square.y
square.hitArea = hitArea;
addChild( square );
addChild( hitArea );