Beenden
  • Globale Community
    • Sprache:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티

Play and Stop an audio with animate cc

Neu hier ,
Feb 29, 2016 Feb 29, 2016

Good evening, i'm new to the flash/animate universe and i have some questions about it.

I'm trying to create an html5 canvas document where there is a button who has to play and stop a sound.

Following a tutorial instruction i have been able to animate the button and make it sound after the is clicked, but i need to use it also to stop the sound.

How can i do that?

thanks for answers

THEMEN
Anleitungen
19.1K
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
LEGENDE ,
Feb 29, 2016 Feb 29, 2016
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Neu hier ,
Feb 29, 2016 Feb 29, 2016

thanks but i'm trying to do it not with code, or i'd used a library but using  the animate button states and code snippets. the problem is that when i add an audio file to the button i just can play it as an event, i don't know how to use the stop event because the software does not make me select it

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
LEGENDE ,
Feb 29, 2016 Feb 29, 2016

You can't do this without code (and code snippets are, of course, code).

How, exactly, are you currently making the audio file play?

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Neu hier ,
Feb 29, 2016 Feb 29, 2016

hi man, sorry if i had not thank you before for the answer but i was on mobile, i'll do now for both answers D.

It's my first time with easejs so i still don't know functions and code snippets. I have a button. I imported into the library a sound that i want to play when it is pressed. I double clicked on the button and i created a keyframe for the down state of the button and i used it to play the audio.

I don't know why if i go on another frame why i can't select the "stop" event and give it to a button state

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
LEGENDE ,
Feb 29, 2016 Feb 29, 2016

I'm going to assume that by "used it to play the audio", you mean you placed the audio directly on the timeline. In that case, the only way to stop it prematurely is with this:

createjs.Sound.stop();

This will kill ALL currently playing audio.

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Neu hier ,
Feb 29, 2016 Feb 29, 2016

No i imported it into the library. I would make a screenshot of it, but unfortunately the app is in italian so i think that it would be quite useless. Thanks for your advices

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
LEGENDE ,
Feb 29, 2016 Feb 29, 2016

Importing audio into the library doesn't make it play.

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Neu hier ,
Feb 29, 2016 Feb 29, 2016

as you can see there is the down (the yellow one) state of the button with a keyframe and on the right the mp3 selected in the library.

Doing that i imported the audio file in the timeliine?

Screenshot 2016-02-29 22.24.45.png

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
LEGENDE ,
Feb 29, 2016 Feb 29, 2016

So yes, you did place the audio on the timeline, just like I said. That Name/Nome dropdown isn't the library. The Library/Libreria tab is the library.

If you want to start and stop the sound by clicking on the same button, that's not going to work. You're going to need some code to track the button state and determine whether it should be starting or stopping the sound.

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Neu hier ,
Feb 29, 2016 Feb 29, 2016
AKTUELL

yeah i have been able to do it with the animation of the button but not with the button. is there a code reference to see what functions i have to use to do what you said?

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines