A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Volume and Pan control with external swfs and mp3s?

  1. #1
    Junior Member
    Join Date
    Feb 2004
    Location
    Liverpool, UK
    Posts
    16

    Volume and Pan control with external swfs and mp3s?

    Hi,

    I need some help, I decided to expand my knowledge of Flash with sound. And I would like to have on my Flash jukebox; a volume slider and pan control. I'd like to learn how to do this with swfs and mp3s. As I know how to play, stop etc using external swfs and streaming mp3s.

    Can anyone point in the right direction of tutorials, help etc? I have been googling for hours and not turning up anything...

    My jukebox contains several external sound files, the only things I ran across was something for a single sound file.

    This is the current state of my jukebox; http://www.pixelghetto.com/iclick/index-white.html

    Any help is greately appreciated!

    Thanks,
    Simon

  2. #2
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,488
    Name all loaded sounds using the same sound object name. Then one pan and one volume slider will control whichever one is playing at the time.
    Attached Files Attached Files

  3. #3
    Junior Member
    Join Date
    Feb 2004
    Location
    Liverpool, UK
    Posts
    16
    I don't quite follow!

    The example file had a parameter of "music0.mp3" but that mean it would only work with one sound file? I am a tad lost at this point now. Surely it'd need some kinda generic name. Otherwise it will only pan and volume one sound, as I have many? Sorry if I seem abit dense, as I am just learning this stuff.

  4. #4
    Junior Member
    Join Date
    Feb 2004
    Location
    Liverpool, UK
    Posts
    16
    Unless I have that in each swf, with the mySound name reletive to the mp3 name. O1.mp3, 02, mp3 etc. So it'd load the sound and the volume and pan with it?

  5. #5
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,488
    If you use loadSound,

    mySound = new Sound();
    mySound.loadSound("music1.mp3", true);

    The sound object to target is mySound. Use that over and over, just changing the name of the sound file to load, music0.mp3, music0.mp3, music2.mp3, whatever. The important part is the sound object name, mySound.

    If your loading sounds in a swf with nothing but the sound in it, you need to add a dummy sound object so you can target that sound:

    mySound = new Sound(this);

    Same thing, you target the sound object to control it, using whatever the full path to it may be. In my example, it was _root.mySound.

  6. #6
    Registered User
    Join Date
    Apr 2001
    Location
    Akron OH, USA
    Posts
    4,841
    another way to think of it, is that a sound object is a container for mp3, much like a level or movie clip is a container for an external SWF. You tell the container what to do not the sound or swf itself.

    Put the sound in the container, using loadSound().
    Control pan and volume by telling the container to change pan or volume.

    mp3Player = new Sound(this); // create the container
    mp3Player.loadSound("anyold.mp3",true); // put sound in the container
    mp3Player.setVolume(50); // change volume of whatever sound in container

  7. #7
    Junior Member
    Join Date
    Feb 2004
    Location
    Liverpool, UK
    Posts
    16
    Thanks for the help, after a good nights sleep and coming back to it. It's really obvious to me now. And it worked! So much thanks again!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center