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

enlace HTML a fotogramas me da error

Estas en el tema de enlace HTML a fotogramas me da error en el foro de Flash y Actionscript en Foros del Web. Buenos días Seguí un tutorial de http://www.codigoactionscript.org/ej...#comment-26863 Pero este código me da un error: Cita: 1067: Implicit coercion of a value of type String to ...
  #1 (permalink)  
Antiguo 06/01/2012, 10:19
Avatar de ceaped  
Fecha de Ingreso: febrero-2004
Mensajes: 2.185
Antigüedad: 20 años, 2 meses
Puntos: 9
Pregunta enlace HTML a fotogramas me da error

Buenos días
Seguí un tutorial de http://www.codigoactionscript.org/ej...#comment-26863

Pero este código me da un error:

Cita:
1067: Implicit coercion of a value of type String to an unrelated type Number.
Cita:
stop();

texto.htmlText="Troiae qui <a href='event:1'>primus</a> ab oris Italiam, fato <a href='event:2'>profugus</a>, Laviniaque venit litora, multum ille et terris <a href='event:3'>iactatus</a> et alto vi superum saevae memorem Iunonis ob iram";

texto.addEventListener(TextEvent.LINK,clica);

function clica(event:TextEvent) {

var accion:Number=event.text;

switch (accion) {
case 1 :
gotoAndStop(5);
break;
case 2 :
gotoAndStop(10);
break;
case 3 :
gotoAndStop(15);
break;
}
}
Que fallo tiene?

Gracias por su ayuda
__________________
Diseñador Gráfico publicitario
  #2 (permalink)  
Antiguo 07/01/2012, 06:53
Avatar de ceaped  
Fecha de Ingreso: febrero-2004
Mensajes: 2.185
Antigüedad: 20 años, 2 meses
Puntos: 9
Respuesta: enlace HTML a fotogramas me da error

Hola a todos
Encontré la solución para quien tenga el mismo problema. Pongo el código correcto:

Cita:
stop();

texto.htmlText = "Troiae qui <a href='event:1'>primus</a> ab oris Italiam, fato <a href='event:2'>profugus</a>, Laviniaque venit litora, multum ille et terris <a href='event:3'>iactatus</a> et alto vi superum saevae memorem Iunonis ob iram"
texto.addEventListener(TextEvent.LINK,clica);
function clica(event:TextEvent){
var accion:String = event.text;
switch (accion) {
case "1" :
gotoAndStop(5);
break;
case "2" :
gotoAndStop(10);
break;
case "3" :
gotoAndStop(15);
break;
}
}
Los 2 errores estaban en la línea:

Cita:
var accion:String = event.text;
que debía ser "String" y no Number.

Y al Ser un String cada caso debe ir entre comillas:

Cita:
case "1" :
Espero que a alguien le sirva

Mucha suerte
__________________
Diseñador Gráfico publicitario

Etiquetas: actionscript, as3, enlace, fotogramas, html
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 11:31.