• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

animate cc for canvas how to import sound

Explorer ,
Jul 04, 2017 Jul 04, 2017

Copy link to clipboard

Copied

I have tried multiple code permutations to get my sounds to work correctly with recent versions of animate cc.

If I simply import sound to the animate library, it does not play from a command like:

var audio1 = createjs.Sound.play("mysound");

I eventually got it working but I had to first import it to the library and then drag the sound to the timeline for it to work. It means I would have to hide the sounds after a stop() on the timeline or you'd get an almighty row when the canvas started to run? Surely that can't be right.

Is there anywhere a clear walkthrough for correctly adding sound to animate cc for canvas?

Also, is there a way to ensure sounds are loaded before the canvas runs?

Previously I was using http://code.createjs.com/preloadjs-0.6.1.min.js  with a json file for the sound imports but I am not sure it is having an effect any more. Should I stop doing that?

I am quite confused at the moment!

Views

1.5K

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
community guidelines

correct answers 1 Correct answer

LEGEND , Jul 04, 2017 Jul 04, 2017

For the second question, on many browsers, especially mobile, it requires a user action to trigger sound. So even if there was a way to play sound before the canvas runs, the user would not hear the sound.

About using sound from code, there's a not very obvious feature. When you try to play a sound, the name you use isn't the name it has in the Name column in the Library, it's the name in the Linkage column. The not-obvious thing is that you can double-click on the Linkage column, then type in th

...

Votes

Translate

Translate
LEGEND ,
Jul 04, 2017 Jul 04, 2017

Copy link to clipboard

Copied

For the second question, on many browsers, especially mobile, it requires a user action to trigger sound. So even if there was a way to play sound before the canvas runs, the user would not hear the sound.

About using sound from code, there's a not very obvious feature. When you try to play a sound, the name you use isn't the name it has in the Name column in the Library, it's the name in the Linkage column. The not-obvious thing is that you can double-click on the Linkage column, then type in the name of your sound. You should try to avoid using exotic characters or spaces. So, an example would be where you have in the Name column:

my long named sound.mp3

you double-click the lInkage column and type in:

mysound

then this will work, without needing to drag the sound to the timeline:

var audio1 = createjs.Sound.play("mysound");

Votes

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
community guidelines
Explorer ,
Jul 04, 2017 Jul 04, 2017

Copy link to clipboard

Copied

LATEST

Thanks, that seems to have done the trick. That linkage column is indeed not very obvious.

Votes

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
community guidelines