Sound Pan + Volume Control by Warrior
Sound Pan + Volume Control
by Warrior
 
The following tutorial will cause a sound in a clip to react to the mouse movement.
Assuming the movie size is 550 x 400, the sound pans left and right with the mouse's horizontal movement and increases or decreases the volume with the mouse's vertical movement.
 
Insert a Movie Clip and place it outside the stage.
 
 
Import your sound and attach it in the library with the name “music”. Place this code on the movieclip;
 
  1. onClipEvent (load) {
  2. // Create a new Sound Object and attach the Sound music to it
  3. MySound = new Sound(this);
  4. MySound.attachSound("music");
  5. MySound.start(0, 1000);
  6. }
  7.  
  8. onClipEvent (enterFrame) {
  9. // Measure the mouse's horizontal location & set the Pan accordingly
  10. mouseX = (_root._xmouse / 550 *200);
  11. MySound.setPan(mouseX - 100);
  12. // Measure the mouse's Vertical location & set the volume
  13. mouseY = (_root._ymouse / 400 *100);
  14. MySound.setVolume(100 - MouseY);
  15. }
 
Here is the working version that you can try.
 

FlashVacuum Flash ActionScript Tutorial CyanBlue subQuark JT

You do not have the Flash plugin installed, or your browser does not support Javascript.

 

 

   |      |      |   Last Modified: July 17, 2009 @ 4:25 am