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
  • 1434 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

Upon further looking the sound is set as event rather than stream inside the movieclip, however I can't change it to stream due to it being an HTML5 document, and while an easy fix would be to convert it to AS3, it's a class project so it has to be HTML5, can you think of anyway to kind of sneak an event in there in order to have it start playing? Or will I just need to move it to the main timeline?

kglad
Community Expert
Community Expert
October 11, 2020

Sounds starts at frame 0, and the movieclip path is this.Combo.Bomb


start the sound on frame 5, if that's what you want it to play when you execute that

 root.Combo.Bomb.gotoAndPlay(5);