Foros del Web » Creando para Internet » Flash y Actionscript »

Pude con numeros, pero no con letras

Estas en el tema de Pude con numeros, pero no con letras en el foro de Flash y Actionscript en Foros del Web. Hola tengo una animación flash en la que: En un input text escribo un numero i al darle un boton me lo dice, la variable ...
  #1 (permalink)  
Antiguo 15/02/2003, 15:07
Avatar de ocionet  
Fecha de Ingreso: agosto-2002
Ubicación: Costa Brava, Catalunya
Mensajes: 605
Antigüedad: 21 años, 7 meses
Puntos: 0
Pude con numeros, pero no con letras

Hola tengo una animación flash en la que:

En un input text escribo un numero i al darle un boton me lo dice, la variable de este es : numberEntry .

Luego en la libreria de ese .fla hay una carpeta llamada "sounds" donde tengo .wav que dicen con "cien" , "mil", "millones" , i luego .wav de numeros: 0-20 i los 30,40,50,60 hasta 90.


Lo que quiero hacer es que ahora esta animacion tambien me hable, se que debería poner .wav con el sonido correspondiente a cada letra, he estado haciendo pruebas pero no logro nada.

Aquí pongo el actionscript que tengo pogramado, me podria algiuen ayudar a hacer esta transformación a esta animación?


Código:
var arrGroups = new Array("","thousand","million");
wait = 1000; // assumed length of each sound


function tick() {
	if ( arrSpeech.length<=0 ) {
		ticking = false;
	} else if (getTimer()>=time+wait) {
		// get a new sound
		var snd = new Sound();
		snd.attachSound( arrSpeech.shift() );
		snd.start();
		time = getTimer();
	}
}


function say(num) {
	arrSpeech = new Array();
	// num needs to be a string:
	num += "";
	// how many digits do we have?
	var len = num.length;
	// create an array to hold each group of three digits:
	var arr = new Array();
	// loop through num, splitting it into threes:
	for (var i=0; i<len; i+=3) {
		var x = len-i;
		arr[i/3] = num.substring(x-3,x);
	}
	arr.reverse();
	for (var i=0; i<arr.length; i++) {
		construct(arr[i],arrGroups[(arr.length-i-1)]);
	}
	time = getTimer()-wait;
	ticking = true;
}


function construct(str,grp) {
	if (str.charAt(0)=="0") str = str.substring(1,str.length);
	if (str.charAt(0)=="0") str = str.substring(1,str.length);
	// 'str' is the number as a string
	// 'num' is the number as an integer
	var num = Number(str);
	if (num<=20) {
		addSound(str);
	} else if (num<100) {
		addSound(str.charAt(0)+"0");
		addSound(str.charAt(1));
	} else {
		addSound(str.charAt(0));
		addSound("hundred");
		var sub = str.substring(1,str.length);
		construct(sub,"");
	}
	addSound(grp);
}

function addSound(str) {
	if ( (str.length>0) && (Number(str)!=0) ) {
		trace("adding " + str);
		var len = arrSpeech.length;
		arrSpeech[len] = str;
	}
}

say(numberEntry);

GRacias.
__________________
Videos de impacto y divertidos
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 05:26.