TOUCH_OVER and TOUCH_OUT not working with Sprite

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);

I tried it, TouchEvent is not working, you can use MouseEvent instead. Or using legacy mode another option.

Hey guys,

Looking at the TouchEvent class, it appears that there are a few event types we are not dispatching. Yeah, you should be able to use MouseEvent safely with OpenFL, and have it work even on touch screens. We’ll keep in mind for something to build out for completeness