Comunidad de diseño web y desarrollo en internet online

Problema con action Sonido

Citar            
MensajeEscrito el 30 Nov 2009 07:00 pm
hola:

Tengo un problemita con un sonido. Este es un botón que cree que reproduce el sonido desde AS. Quiero que el sonido se reproduzca siempre, pero como lo estoy haciendo solo sucede si uno le pone el mute y vuelve y activa el sonido. Si no se hace esto el sonido se reproduce la primera vez y ya no se vuelve activar hasta que uno le de click de nuevo al botón de sonido/mute.

Este es el script que estoy colocando en un frame vacio en la linea principal.

Código ActionScript :

var pausa:Number = 0;
var estado:Number = 1;

btn_son.stop();

_root.onLoad = function(){
    Sonido = new Sound();
    Sonido.attachSound("Sonido");
   Sonido.start(0,0);
}

btn_son.onPress = function (){
    if (estado == 0){
         Sonido.start(pausa/1000);
        estado = 1;  
        btn_son.gotoAndStop("pause");
    } else {
           pausa = Sonido.position;
           Sonido.stop();
           estado = 0;
        btn_son.gotoAndStop("play");
    }

if (noRepeat == undefined) { 
    var noRepeat:Number; 
    noRepeat = 1
   }; 
    Sonido.onSoundComplete = function() { 
    this.start(); 
    }
}

Por wilsospm

13 de clabLevel



 

msie8
Citar            
MensajeEscrito el 30 Nov 2009 08:25 pm
Je! A mi también me ha traido a veces problema el listener de onSoundComplete, fijate igual de probar así:

Código ActionScript :

var pausa:Number = 0; 
var estado:Number = 1; 
 
btn_son.stop(); 
 
Sonido = new Sound(); 
Sonido.attachSound("Sonido"); 
Sonido.start(0,0); 
Sonido.onSoundComplete = function() {  
    this.start();  
} 
 
btn_son.onPress = function (){ 
    if (estado == 0){ 
        Sonido.start(pausa/1000); 
        estado = 1;   
        btn_son.gotoAndStop("pause"); 
    } else { 
           pausa = Sonido.position; 
           Sonido.stop(); 
           estado = 0; 
        btn_son.gotoAndStop("play"); 
    } 
 
if (noRepeat == undefined) {  
    var noRepeat:Number;  
    noRepeat = 1 
   };  
}


Sino puedes evaluar con position cuando termina el sound.

Saludos, Hernán . -

Por Hernán

BOFH

6148 de clabLevel

19 tutoriales
23 articulos

Genero:Masculino   REC Desarrollador de GAIA

Marketing & IT

firefox
Citar            
MensajeEscrito el 30 Nov 2009 09:11 pm
Muchas Gracias Hernán, con los cambios que me enviaste del código anda perfecto.

Un saludo.

Por wilsospm

13 de clabLevel



 

msie8

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.