un esempio da adattare al tuo caso specifico
Codice PHP:
// sound fade function:
var fadeSound:Object = new Object();
fadeSound.fade = function(s:Sound, t:Number, f:Function):Void {
var fv:Number = s.getVolume();
var ts:Object = new mx.transitions.Tween(this, "fv", null, s.getVolume(), t, 1, true);
ts.path = this;
ts.onMotionChanged = function() {
s.setVolume(this.path.fv);
};
ts.onMotionFinished = function() {
f();
};
};
// create and manage sound object
var s:Sound = new Sound(this);
s.loadSound("file.mp3", true);
s.onSoundComplete = function() {
this.start(0, 1);
};
//usage with "s" instance of Sound class:
fadeOut.onRelease = function() {
function traccia() {
trace("fade out eseguito!");
}
fadeSound.fade(s, 0, traccia);
};
fadeIn.onRelease = function() {
function traccia() {
trace("fade in eseguito!");
}
fadeSound.fade(s, 100, traccia);
};