Highlighted

Sound Function Doesn't work on TouchEvent

Participant ,
Oct 12, 2020

Copy link to clipboard

Copied

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

 

 

TOPICS
ActionScript, Code

Views

41

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Sound Function Doesn't work on TouchEvent

Participant ,
Oct 12, 2020

Copy link to clipboard

Copied

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

 

 

TOPICS
ActionScript, Code

Views

42

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Oct 12, 2020 0
Adobe Community Professional ,
Oct 12, 2020

Copy link to clipboard

Copied

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?

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 12, 2020 0
Participant ,
Oct 12, 2020

Copy link to clipboard

Copied

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?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 12, 2020 0
Adobe Community Professional ,
Oct 12, 2020

Copy link to clipboard

Copied

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

 

Screenshot - 10_12_2020 , 1_46_17 PM.png

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 12, 2020 0
Participant ,
Oct 12, 2020

Copy link to clipboard

Copied

So when I publish an AIR for Android APK file the touch layer goes with it?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 12, 2020 0
Participant ,
Oct 12, 2020

Copy link to clipboard

Copied

Following with your advice I found out that  It works with Adobe Animate emulator but not with the Android Studio emulator 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 12, 2020 0
kglad LATEST
Adobe Community Professional ,
Oct 12, 2020

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 12, 2020 0