A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Volume control for external SWF's

  1. #1
    Senior Member Sir Yendor's Avatar
    Join Date
    Sep 2001
    Location
    Over here
    Posts
    1,140

    Volume control for external SWF's

    I'm trying to find a tutorial that will allow the user to control the volume of external SWF's that load after a particular button is clicked.

    I don't want the volume control to affect the volume on my buttons, etc, only on the loaded SWF's.

    Any ideas?

  2. #2
    Lifesaver Lightwave Network's Avatar
    Join Date
    Sep 2002
    Location
    Denver, CO, USA
    Posts
    649
    Wow, that's a fun one. I'm not exactly sure how to go about it, but a few ideas come to mind.

    Load your external SWFs into a MOVIE CLIP. Not a level (at least I don't think a level will work in this one...)

    Make sure your MC has an instance name...like "loadedMovie".

    Then, after the movie loads, you'll have to create a sound object:

    mySubSound = new Sound(loadedMovie)

    I think you should be able to control volume levels from there with mySubSound.setVolume()



    ... gimme just one more line of code to ease the pain.

    http://www.ln.tv
    http://www.davevillano.com
    http://www.premierloftsdenver.com
    http://www.backyard.cc -- coming soon!


  3. #3
    Senior Member Sir Yendor's Avatar
    Join Date
    Sep 2001
    Location
    Over here
    Posts
    1,140
    Would it make life easier if I didn't care if the volume controls also affected the buttons sounds?

    But back to your solution for a minute, it sounds like if I just follow one of the tutorials on creating a "sound object" and then follow one of the tutorials on making a volume slider it should work.

    Hmmm. I'll have to try that over the weekend.

    Thanks for the idea.

  4. #4
    Lifesaver Lightwave Network's Avatar
    Join Date
    Sep 2002
    Location
    Denver, CO, USA
    Posts
    649
    No sweat. Ultimately, you could make it really easy and basic simply by using Macromedia's tutorial in the ActionScript reference on how to make a global sound object. You can do this by not defining a movie clip in your new Sound() object:

    myGlobalSound = new Sound(); //this sound object can control ALL sounds in the Flash movie.

    But, with what I mentioned, you should be able to localize that sound object to just loaded movie, as long as the movie has an instance name (I don't think new Sound(_level1) works...it might though--worth trying.)

    Then, volume sliders are pretty easy. Just keep the value of the variable that the slider changes between 0 and 100, and use mySoundObject.setVolume(sliderVarValue) to dynamically change the volume.


    ... gimme just one more line of code to ease the pain.

    http://www.ln.tv
    http://www.davevillano.com
    http://www.premierloftsdenver.com
    http://www.backyard.cc -- coming soon!


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