Tema: Fade volumen
Ver Mensaje Individual
  #3 (permalink)  
Antiguo 19/12/2004, 12:46
Avatar de pcMan
pcMan
 
Fecha de Ingreso: diciembre-2003
Ubicación: Navojoa, Mexico
Mensajes: 29
Antigüedad: 20 años, 4 meses
Puntos: 0
Que tal,

Puedes hacer algo como esto:
1- Importar un sonido (.mp3, .wav, etc) a la biblioteca y, en la opción de "Vinculación" ponerle como nombre de ID "sonido".
2- Crear 2 botones y asignarles como nombres de instancia "iniciar_btn" y "detener_btn".
3- En las acciones del primer fotograma pones el siguiente código:
Código:
// creamos el objeto sound al iniciar y agregamos un sonido de la biblioteca
_snd = new Sound();
_snd.attachSound("sonido");

// aumento/decremento al hacer fade-in o fade-out
c = 3;

// acciones para el boton "detener_btn"
detener_btn.onRelease = function() {
	iniciar_btn.enabled = true;
	this.enabled = false;
	trace("fade-out iniciado");
	onEnterFrame = function () {
		_snd.setVolume(_snd.getVolume()-c);
		trace(_snd.getVolume());
		if (_snd.getVolume()<=0) {
			delete this.onEnterFrame;
			_snd.stop();
			trace("fade-out terminado");
			trace("sonido detenido");
		}
	};
};

// acciones para el boton "iniciar_btn"
iniciar_btn.onRelease = function() {
	detener_btn.enabled = true;
	this.enabled = false;
	_snd.start();
	if (_snd.getVolume() == 100) {
		_snd.setVolume(0);
	}
	trace("sonido iniciado");
	trace("fade-in iniciado");
	onEnterFrame = function () {
		_snd.setVolume(_snd.getVolume()+c);
		trace(_snd.getVolume());
		if (_snd.getVolume()>=100) {
			delete this.onEnterFrame;
			trace("fade-in terminado");
		}
	};
};
4- Probar la película.

Saludos ;)

Última edición por pcMan; 19/12/2004 a las 12:49