Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I fade out a streaming audio file? 1

Status
Not open for further replies.

beeej21

Technical User
Jul 7, 2003
67
US
Hi all,
I have a flash file that utilizes the "//Load Streaming mp3 behavior" ( found in Windows/Behaviors/Sound/Load mp3 Streaming File ) on a keyframe in the timeline.

That part works just fine. For now, I have a button that utilizes the "//stopAllSounds Behavior". That part works fine too.. however, I don't like the abrupt sound stoppage. I'd really like to have the streaming file fade out instead of stop suddenly. I don't care whether this happens via a button behavior or on a keyframe. Right now I'd like to use whichever is easiest because my ActionScripting knowledge is really poor.

Here's the link to the site I am building ( still rough ). The flame pit is the audio on/off switch.


Thanks for your help!
 
Code:
globalSound = new Sound(this);
var audio_volume:Number = 100;

function fade_out() {
    this.onEnterFrame = function() {
        if (globalSound.getVolume()>0) {
            trace(audio_volume);
            globalSound.setVolume(audio_volume);
            audio_volume -=5;
        } else {
            audio_volume = 0;
            globalSound.setVolume(audio_volume);
            delete this.onEnterFrame;
        }
    };
};

// usage...

Rather than stopAllSounds(), simply call the fade out function...

on(release){
fade_out();
}

Regards. Web Hosting - Web Design
03/13/05 -> OLDNEWBIE VS FLASHKIT
 
Thanks so much for the tip and the code, Oldnewbie! I've got the sound fading out now.

By any chance would you or anyone else know how to make the streaming mp3 repeat or loop?

Here's the code that resides on a keyframe in the timeline:

//Load Streaming mp3 behavior
if(_global.Behaviors == null)_global.Behaviors = {};
if(_global.Behaviors.Sound == null)_global.Behaviors.Sound = {};
if(typeof this.createEmptyMovieClip == 'undefined'){
this._parent.createEmptyMovieClip('BS_myMusic',new Date().getTime()-(Math.floor((new Date().getTime()) /10000)*10000) );
_global.Behaviors.Sound.myMusic = new Sound(this._parent.BS_myMusic);
} else {
this.createEmptyMovieClip('_myMusic_',new Date().getTime()-(Math.floor((new Date().getTime()) /10000)*10000) );
_global.Behaviors.Sound.myMusic = new Sound(this.BS_myMusic);
}
_global.Behaviors.Sound.myMusic.loadSound("sample.mp3",true);


Is there a line I could add to make this music repeat once it reaches the end? Thanks again for all the help.
 
I tried kennybellew.com to see if there was a simple solution to making a streaming mp3 repeat. I didn't find anything. Is it possible to just have this function by adding a line in the actionscript or do I have to dive a little more deeper into complication?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top