AS2 setVolume to zero turn off video volume
Why my Video volume turns off when I run mySound.setVolume(0) ?To understand this, compare AS2 and AS3
In AS3, to play a sound file, you need to create a Sound object, that is played through a SoundChannel object.- var mySound : Sound = new Sound();
- var myChannel : SoundChannel;
- //load a sound file
- mySound.load(new URLRequest("soundfile.mp3"));
- //then play it through the SoundChannel
- myChannel = mySound.play();
To play and control separately two differents soundfiles playing simultaneously, you need two differents SoundChannel.
And in AS3, video component has its own SoundChannel.
In AS2, there is no SoundChannel, but it is almost the same way. Each MovieClip or Containeur, has its own depth, and you can't display two of them in the same depth. With Sound object it almost the same, you can play two differents soundfiles in a depth, but you can't control them separately because they are using the same Channel(depth).If your are facing this trouble you might have something similar to this code :
- //In the same container (MovieClip or Stage)
- var myVideo:Video;
- var mySound:Sound = new Sound(this);
- //... mySound.loadSound(...), blablabla
- //And
- mySound.setVolume(0);
- //wich also turns of myVideo sound
So the video component and the sound object has the same parent(container). To skip this trouble, just create a container for the sound object.
- var myVideo:Video;
- var soundContainer:MovieClip = this.createEmptyMovieClip("mySoundContainer" , this.getNextHighestDepth());
- var mySound:Sound = new Sound(soundContainer);
And the problem is solved.
0 comments about this entry