0

When I'm trying to add a sound to TouchEvent Function the sound doesn't work on the Android emulator. But it works fine if I replace the TouchEvent with MouseEvent and test it on Adobe Animate. What am I doing wrong?

Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
var mysound: ClickTap = new ClickTap();
var mySprite: Sprite = new Sprite();
var myTextField: TextField = new TextField();
mySprite.graphics.beginFill(0x336699);
mySprite.graphics.drawRect(0, 0, 40, 40);
addChild(mySprite);
mySprite.addEventListener(TouchEvent.TOUCH_TAP, taphandler);

function taphandler(evt: TouchEvent): void {

    mysound.play();
    myTextField.text = "I've been tapped";
    myTextField.y = 50;
    addChild(myTextField);
  • As a first step toward solution, please, figure out, is it a **Sound** problem or a **TouchEvent** problem, then "edit" your question to narrow the problem down. – Organis Oct 12 '20 at 17:42
  • It's not a sound problem, because as I explained above the sound works when in a similar but slightly different situation. – Steve Ben-Ari Oct 12 '20 at 19:08
  • 1
    Please check if "touch_tap" event is actually dispatched. You might have a different set of events dispatched, say instead of a tap you get a "touch_begin" then a series of "touch_drag" then a "touch_end", and no tap event. – Vesper Oct 13 '20 at 14:04
  • Not clear... Your title says _"Function does not work"_ but then your post says _"...The sound doesn't work on the Android emulator."_. **(1)** Are you getting an `"I've been tapped"` update? If NOT then your tap event didn't fire, maybe test on a real Android device to fire correctly (_ie:_ try not just using a touchscreen PC). **(2)** Unless things have changed, a `MouseEvent.CLICK` sends the same signal as a "single tap", so for same result, you can still use a `MouseEvent` on you Sprite and it will fire when a user taps the Sprite. – VC.One Oct 13 '20 at 17:34

0 Answers0