Comunidad de diseño web y desarrollo en internet online

Crear hipervinculo en xml

Citar            
MensajeEscrito el 12 Dic 2009 10:50 pm
Hola!! si alguien pudiera ayudarme... estoy cargando texto e imagen a mi swf desde un xml pero necesito que dependiendo la nota que cargue haya un hipervinculo a x pagina y la abra en ventana nueva pero no se como hacer eso.. gracias...

Código XML :

<noticias>
   <noticia> 
      <titulo>Titulo 1</titulo>
      <mensaje>Mensaje 01</mensaje>      
      <image>nota1.jpg</image>
   </noticia>
   <noticia> 
      <titulo>Titulo 2</titulo>
      <mensaje>Mensaje 02</mensaje>      
      <image>nota2.jpg</image>
   </noticia>
   <noticia> 
      <titulo>Titulo 3</titulo>
      <mensaje>Mensaje 03</mensaje>      
      <image>nota3.jpg</image>
   </noticia>
</noticias>

Por arracadas

7 de clabLevel



 

opera
Citar            
MensajeEscrito el 13 Dic 2009 04:56 am
Tienes dos maneras de enviar a una página HTML, usando getURL o con código html:

1. getURL

Código ActionScript :

getURL("pagina.html","_blank");


2. Código HTML

Código ActionScript :

myTextField.htmlText = "<a href='pagina.html'>Click Aquí</a>";


En cuanto a ls páginas que quieres ir, podrías cargarlas como un nodo nuevo en el XML algo como:

Código XML :

<nodo>www.mipagina.com


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 13 Dic 2009 06:05 am
si se mas o menos utilizar gerURL y los otros pero via XML no se donde se coloquen si pudieras darme un ejemplo si no es mucho pedir aqui estan los datos gracias de antemano...

este es el codigo en mi SWF

Código ActionScript :

System.useCodepage = true; 
var indice:Number; 
var noticias_xml:XML; 

function cargarDatos(_indice:Number){
var fecha:String;
var titulo:String;
var mensaje:String;
var imagen:String;
var link:String;
fecha = noticias_xml.firstChild.childNodes[_indice].attributes.fecha;
titulo = noticias_xml.firstChild.childNodes[_indice].firstChild.firstChild.nodeValue;
mensaje = noticias_xml.firstChild.childNodes[_indice].firstChild.nextSibling.firstChild.nodeValue
imagen = noticias_xml.firstChild.childNodes[_indice].lastChild.firstChild.nodeValue
      
_root.mensaje_txt.htmlText = "";
_root.mensaje_txt.htmlText += "<p align='center'><font color='#006633' size='12'><b>" + titulo + "</b></font></p>";
_root.mensaje_txt.htmlText += "<p><font size='10'>" + mensaje + "</font>";
_root.mensaje_txt.htmlText += "<font color='#666666' size='10'>Publicado: " + fecha + "</font></p>";
_root.pantalla_mc.loadMovie(imagen);   
}

siguiente_btn.onPress = function(){   
   if(noticias_xml.firstChild.childNodes[indice+1] != null){
         indice++; 
         cargarDatos(indice);         }
   }

anterior_btn.onPress = function(){
   if(noticias_xml.firstChild.childNodes[indice-1] != null){
         indice--;
         cargarDatos(indice);         }
   }   
   
indice=0;
noticias_xml = new XML();
noticias_xml.ignoreWhite = true;

noticias_xml.load("noticias.xml");

noticias_xml.onLoad = function(){
      cargarDatos(indice);         
}


y este el codigo de mi XML

Código XML :

<?xml version="1.0" encoding="iso-8859-1"?>
<noticias>
 <noticia>        
  <titulo>Titulo 1</titulo>
  <mensaje>Mensaje 01</mensaje>             
  <image>nota1.jpg</image>    
 </noticia>    
  <noticia>        
  <titulo>Titulo 2</titulo>       
  <mensaje>Mensaje 02</mensaje>             
  <image>nota2.jpg</image>    
 </noticia>    
 <noticia>        
  <titulo>Titulo 3</titulo>       
  <mensaje>Mensaje 03</mensaje>             
  <image>nota3.jpg</image>    
 </noticia> 
</noticias>

Por arracadas

7 de clabLevel



 

msie7
Citar            
MensajeEscrito el 13 Dic 2009 07:50 am
arracadas, una URL es otro dato, nada más, tienes que usarlo como lo que ya tienes dentro del código. Agrega dentro del XML un nodo llamado "URL" o lo que quieras, dentro pon el dato.

Y luego la carga es la misma, y usarlo es lo mismo que como estas haciendo aquí:

Código ActionScript :

_root.mensaje_txt.htmlText += "<p align='center'><font color='#006633' size='12'><b>" + titulo + "</b></font></p>"; 


Solo que en vez de ponerlo así, lo pones como te dije:

Código ActionScript :

_root.mensaje_txt.htmlText += "<a href='"+url_desde_xml+"'>Click Aquí</a>";


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 13 Dic 2009 10:10 pm
gracias voy a probarlo ...

Por arracadas

7 de clabLevel



 

msie7
Citar            
MensajeEscrito el 14 Dic 2009 06:54 am
ya lo tengo.... ya me hace el vinculo a la otra pagina pero no lo hace en ventana nueva :P espero no molestar demaciado gracias...

Por arracadas

7 de clabLevel



 

msie7
Citar            
MensajeEscrito el 14 Dic 2009 07:22 am
Agregale target="_blank" para que vaya a una ventana nueva.

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 14 Dic 2009 04:38 pm
Gracias ya lo habia intentado con target
porque me marcaba error con target="_blank"
pero el problema era la comilla quedo asì:

Código :

"<a href='" + vinculo + "' target='_blank'> " + mensaje + " </a>";


gracias por todo Hernán

Por arracadas

7 de clabLevel



 

msie7
Citar            
MensajeEscrito el 14 Dic 2009 05:56 pm
Si quisiera poner el vinculo en la imagen no en el texto como seria?

Por arracadas

7 de clabLevel



 

msie7
Citar            
MensajeEscrito el 14 Dic 2009 08:20 pm
Listo ya lologre!!!! con getURL el problema era la comilla sencilla al igual que href jejeje gracias por todo suerte

Por arracadas

7 de clabLevel



 

msie7

 

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