Hello!
I have some issues with implementing a button represented by a Sprite.I’m using an Android device so I want to detect whether the touch is over the button or not and I do this with the help of the TOUCH_OVER event. However it is not working and I don’t know why because everything seems ok.
I have the following code:
var playAgainButtonSVG = new SVG(Assets.getText("images/playagain_button.svg"));
var playAgainButton = new Sprite();
playAgainButtonSVG.render(playAgainButton.graphics);
playAgainButton.x = 100;
playAgainButton.y = 100;
playAgainButton.width = Lib.current.stage.stageWidth / 5;
playAgainButton.height = Lib.current.stage.stageWidth / 5;
playAgainButton.addEventListener(TouchEvent.TOUCH_BEGIN,
function (touchEvent: TouchEvent): Void
{
playAgainButtonSVG = new SVG(Assets.getText("images/playagain_button_pressed.svg"));
playAgainButtonSVG.render(playAgainButton.graphics);
}
);
playAgainButton.addEventListener(TouchEvent.TOUCH_OVER,
function (touchEvent: TouchEvent): Void
{
trace("over");
}
);
this.addChild(playAgainButton);