Skip to main content
deborahb44958436
Inspiring
October 12, 2020
Question

Sound Function Doesn't work on TouchEvent

  • October 12, 2020
  • 2 replies
  • 549 views

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

 

 

This topic has been closed for replies.

2 replies

kglad
Community Expert
Community Expert
October 12, 2020

i've never used the android studio emulator. (in general, i've had trouble doing anything useful with android studio.)

 

you don't need a touch layer when testing on touch devices and i strongly suggest you all your testing on a device, not an emulator.

kglad
Community Expert
Community Expert
October 12, 2020

i'm not sure what the emoticon is doing in taphandler but a right paran colon (in the code panel) wouldn't cause that.  and there's no closing curly bracket for taphandler().

 

those both may still  be forum artifacts so do you see any compiler errors in animate? 

 

if not, do you see your textfield respond?

 

if not and no, do you add a touch layer in the emulator?

 

 

deborahb44958436
Inspiring
October 12, 2020

a right paran colon was there in the original code. somehow it didn't copy over when I did copy and paste. the emoji was produced automatically by this site NOT by me. 

I do not get an error message. The sound just doesn't work in the Android emulator but works under Animate tests when I use a mouse event. 

how do I add touch layer in the emulator?

kglad
Community Expert
Community Expert
October 12, 2020

you can't test any touch events in the emulator unless you enable a touch layer: