Skip to main content
Inspiring
October 11, 2020
Answered

Audio inside nested movie clip won't play with the animation

  • October 11, 2020
  • 1 reply
  • 1449 views

The title explains the bulk of it, I'm in HTML5 canvas, and the movie clip plays fine, but the audio in it's timeline isn't playing with it. Here is all the relavent code

 

                var root = this;

                root.Combo.Wire1.gotoAndStop(4);
                
                root.Combo.Bomb.gotoAndPlay(5);
                setTimeout(Explosion, 9500);
            
                function Explosion(){

                       root.House.gotoAndPlay(3);
                    
                }

All of the words listed but not delcared (combo, bomb, house, Wire1, etc.) are the instance names of movieClips that I set up in the Adobe UI. If anyone has any ideas it would be much appreciated. Thanks!

 

This topic has been closed for replies.
Correct answer Ryna5FA2

use console.log or alert to confirm you're goto is doing what you think


1. You aren't understanding the issue, because in HTML5, when you are inside a symbol the sounds can't be played during testing, because you can only set the sound to event inside a symbol rather than stream. So therefore with no stream audio, gotoAndPlay can't play it, what I was asking is if you could think of an event that would allow me to play it when I need it, which-

 

2. I found a solution for. In the library of where all your symbols, bitmaps, and sounds are, you need to set the sound a linkage name. For this example lets use "Bomb", with that set yu need to go just above, or just below the gotoAndPlay line in the frame (doesn't matter which), and put in this code

createjs.Sound.play("LinkageName");

 

Or for this example

 

createjs.Sound.play("Bomb");

 

Make sure to include the quotations in the code, I typed this all out for the sole reason as to mark it as the answer so someone else doesn't have to do hours of research to figure out a single line of code to fix it.

1 reply

kglad
Community Expert
Community Expert
October 11, 2020

there's nothing you showed that would necessarily cause the problem but there's a lot unknown that would cause the problem.

 

if you suspect a code problem, open the test browser's developer console and look for an error.

 

one of the most common problems would be the sound not starting on a played frame and the sound having a sync property of event (instead of stream).  but obviously, no one can say that is your problem.

Ryna5FA2Author
Inspiring
October 11, 2020

There have been no errors and only one warning. The warning being "audio context was not allowed to start" which from my understanding is because modern browsers dont play audio without interaction first. There is plenty of interaction before we get to the part where the audio is supposed to play, so i'm really at a loss