Tobias Menzel
Erfahrenes Mitglied
Hi,
Gruß
.
Code:
var isplaying = false;
var snd = new Sound(this);
snd.onSoundComplete = function() {
this.start(0, 9999);
}
snd.attachSound("musik");
function fadeIn() {
isplaying = true;
snd.setVolume(0);
snd.start();
this.onEnterFrame = function() {
var v = snd.getVolume();
v += (100 - v) / 8
snd.setVolume(v);
if (snd.getVolume() >= 99) {
snd.setVolume(100);
delete this.onEnterFrame;
}
}
}
function fadeOut() {
isplaying = false;
this.onEnterFrame = function() {
var v = snd.getVolume();
v += (0 - v) / 8
snd.setVolume(v);
if (snd.getVolume() <= 1) {
snd.setVolume(0);
snd.stop();
delete this.onEnterFrame;
}
}
}
button_play.onPress = function() {
if (!isplaying) {
snd.stop();
fadeIn();
}
}
button_stop.onPress = function() {
fadeOut();
}
Gruß
.