Yeo Ling Xuan
Yeo Ling Xuan

Reputation: 11

Stop music after scene ends

I got this animation homework.
I wanted to put a couple of bgm in it.
I placed the first one, and it refuses to stop when the scene ends.
I place the music in a individual frameline but it doesn't stop when frames end.
So, I insert a keyframe behind it, and put this codes :

import flash.media.SoundMixer.*;
soundmixer.stopAll();

In which I got the errors :
definition of flash.media.SoundMixer could not be found (twice), for line 1
access of undefined property soundmixer, at line 2.

I also tried stopAllsounds; , which is also undefined (even after I import flash.media)

(ps: there is hardly any codes inside this animation - it only has the codes for the replay button)

Upvotes: 0

Views: 3738

Answers (1)

iND
iND

Reputation: 2649

Try this instead:

import flash.media.SoundMixer;

if(SoundMixer.areSoundsInaccessible() == false) {
  SoundMixer.stopAll();
} else {
  trace("There are inaccessible sounds.");
}

But you may have to check where you are loading the sound files from, and fix the security issues (cf., Adobe SoundMixer docs).


The problem was that you were importing SoundMixer incorrectly (with the ".*" on the end), and you were using it as if it was an instance, rather than a static class.

Upvotes: 2

Related Questions