5

Blog Entry #25

posted in Solving

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.

  1.  
  2. var mySound : Sound = new Sound();
  3. var myChannel : SoundChannel;
  4. //load a sound file
  5. mySound.load(new URLRequest("soundfile.mp3"));
  6. //then play it through the SoundChannel
  7. myChannel = mySound.play();
  8.  

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 :

  1.  
  2. //In the same container (MovieClip or Stage)
  3. var myVideo:Video;
  4. var mySound:Sound = new Sound(this);
  5. //... mySound.loadSound(...), blablabla
  6. //And
  7. mySound.setVolume(0);
  8. //wich also turns of myVideo sound
  9.  

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.

  1.  
  2. var myVideo:Video;
  3. var soundContainer:MovieClip = this.createEmptyMovieClip("mySoundContainer" , this.getNextHighestDepth());
  4. var mySound:Sound = new Sound(soundContainer);
  5.  

And the problem is solved.

0 comments about this entry

Write a comment

edit




Insert :


Recents Blog Entries

posted in Solving

Flash Player 10 freeze randomly on fullscreen

Ho ho ho

posted 2009-12-281 Commentsread more ...

posted in Papervision3D

Christmas book using ViewportLayer

It is an old book made with Papervision ViewportLayer. It shows origami that fold/unfold using Bones. It is a christmas gift for my closest friends and favorites co-workers.

posted 2009-12-240 Commentsread more ...

posted in Papervision3D

Animate parented DisplayObject3D from DAE

This post display how to set up and animate parented DisplayObject3D. Also demonstrate how to localise and fix unwanted behavior.

posted 11-01-20090 Commentsread more ...

posted in Personnal

I am Graduated

Time to work !

posted 15 09 20090 Commentsread more ...

posted in Others

Colors syntaxing AS3 for FlashDevelop

A color file configuration for FlashDevelop

posted 04-08-20090 Commentsread more ...

posted in Papervision3D

Faking solar flare

How I've tried to fake a solar flare with Papervision3D

posted 06-08-20091 Commentsread more ...

posted in Actionscript

Avoiding AS3 security sandbox

A bad method to avoid the security sandbox

posted 14-03-082 Commentsread more ...

posted in Papervision3D

Labyrinth3D Papervision3D and WOWEngine

This game-project called 'WOW that 's a Labyrinth' is still in dev. And unfortunately it should be still for a while.

posted 13-03-092 Commentsread more ...

posted in Works

Coverflow like picture gallery

Absolutely not innovating, but I post my coverflow gallery.

posted 12-03-090 Commentsread more ...