Okay so I'm working in pure as3 (no creative suite or xml). I have a sprite. It draws a large rectangle and then a slightly smaller rectangle. I want to change the color of the slightly smaller rectangle when I hover the mouse over it. Right now though it will either not respond (I can plainly have the mouse over the rectangle and nothing happens) or it is slow to respond. In addition the collision area of the rectangle seems a bit off, ie it responds more frequently when I have the mouse on the upper left corner of the rectangle than when I have the mouse elsewhere on it.
Anyways here's the code I'm using:
public function MAIN()
{
BUTTON_1.graphics.clear();
BUTTON_1.graphics.beginFill(0x000000);
BUTTON_1.graphics.drawRect(188,96,104,24);
BUTTON_1.graphics.endFill();
BUTTON_1.graphics.beginFill(0x0000DC);
BUTTON_1.graphics.drawRect(190,98,100,20);
BUTTON_1.graphics.endFill();
addChild(BUTTON_1);
BUTTON_1.addEventListener(MouseEvent.MOUSE_OVER,MOUSE_OVER_1);
function MOUSE_OVER_1():void
{
removeChild(BUTTON_1);
BUTTON_1.graphics.clear();
BUTTON_1.graphics.beginFill(0x000000);
BUTTON_1.graphics.drawRect(188,96,104,24);
BUTTON_1.graphics.endFill();
BUTTON_1.graphics.beginFill(0x0000A0);
BUTTON_1.graphics.drawRect(190,98,100,20);
BUTTON_1.graphics.endFill();
addChild(BUTTON_1);
}
}
I'm pretty new to as3 so if there's a better way to do this tell me.