Comunidad de diseño web y desarrollo en internet online

Boton con carga de link de xml a flash, ayuda por favor

Citar            
MensajeEscrito el 07 Ago 2008 01:58 pm
Hola, necesito una ayudita por favor. Sucede que he estado avanzando chevere hasta el momento en un baner que llama a texto, fotos y (quisiera que lo haga) enlaces o links. Podran entender que el texto lo carga bien, las fotos ni que decir, pero sucede que al boton no.
Cree el boton el flash y el contenido de boton (es decir "enlace.html") no lo llama y lo reconoce como indefinido.

Quisiera saber si por favor me pueden ayudar. El xml es el siguiente:

Código :

<gallery>

<image
tipo="FOTOSHOW" 
MediaId="1" 
titulo="Inti Raymi" 
descripcion="La Fiesta del Sol en el Cuzco" 
thmb="1.jpg"
lnk="http://www.yahoo.es"
/>

<image
tipo="FOTOSHOWI" 
MediaId="1" 
titulo="Inti Raymi" 
descripcion="La Fiesta del luna en el Cuzco" 
thmb="2.jpg"
lnk="http://www.hotmail.com"
/>

<image
tipo="FOTOSHOWU" 
MediaId="1" 
titulo="Inti Raymi" 
descripcion="La Fiesta del saturno en el Cuzco" 
thmb="3.jpg"
lnk="http://www.gmail.com"
/>

<image
tipo="FOTOSHOWE" 
MediaId="1" 
titulo="Inti Raymi" 
descripcion="La Fiesta del pluton en el Cuzco" 
thmb="4.jpg"
lnk="http://www.google.com"
/>

<image
tipo="FOTOSHOWA" 
MediaId="1" 
titulo="Inti Raymi" 
descripcion="La Fiesta del marte en el Cuzco" 
thmb="5.jpg"
lnk="http://www.amazon.com"
/>

</gallery>


Hasta ahi todo chevere. Ahora les pongo el flash (donde sospecho, se encuentra el real problema):

Código :

System.useCodePage = true;
//loadVariablesNum("titulo_2.txt", 0);
// Xphoto = posicion de inicio del scrool de la imagen

xphoto = 0;
// 
// Widthmovie = Aqui definimos el ancho de la pelicula
widthmovie = 1024;
// 
// Scrollspeed = Definie la velocidad del scroll
scrollspeed = 15;
// 
// widthphoto = el ancho de la imagen a poner en el scroll, en pixeles
widthphoto = 1735;

//CARGAR FOTOS
myPhoto = new XML();
myPhoto.ignoreWhite = true;
myPhoto.onLoad = function(success) {
   //portfolioTag = this.firstChild;
   numimages = this.firstChild.childNodes.length;
   spacing = 100;
   photo.txtMediaId1.text = this.firstChild.childNodes[0].attributes.MediaId;
   photo.txtTipo01.text = this.firstChild.childNodes[0].attributes.tipo;
   photo.txtTitulo01.text = this.firstChild.childNodes[0].attributes.titulo;
   photo.txtDescripcion01.text = this.firstChild.childNodes[0].attributes.descripcion;
   photo.img01.loadMovie(this.firstChild.childNodes[0].attributes.thmb);
   
   //photo.img01.onpress(getURL(this.firstChild.childNodes[0].attributes.lnk, "_blank", "GET"));
   //Link de la foto
   //photo.img01.onRelease{getURL("www.elperuano.com.pe", "_self", "GET");}
   //   photo.img01(press, release) {getURL(this.firstChild.childNodes[0].attributes.thmb, "_self", "GET");}


   //link load
   //photo.btn1.onPress = function() {
   //
   //link = this.firstChild.childNodes[0].attributes.lnk;
   //getURL("javascript:launchwin('"+link+"','newwindow','toolbar=no,directories=no,menubar= no,scrollbars=no,width=276,height=155,resize=no')");
   //
   //};


   photo.btn1.onPress = function() {
      {
         link = "http://"+this.firstChild.childNodes[0].attributes.lnk;
         getURL(link, "_blank");
      };
   };


   photo.txtMediaId2.text = this.firstChild.childNodes[1].attributes.MediaId;
   photo.txtTipo02.text = this.firstChild.childNodes[1].attributes.tipo;
   photo.txtTitulo02.text = this.firstChild.childNodes[1].attributes.titulo;
   photo.txtDescripcion02.text = this.firstChild.childNodes[1].attributes.descripcion;
   photo.img02.loadMovie(this.firstChild.childNodes[1].attributes.thmb);


   photo.txtMediaId3.text = this.firstChild.childNodes[2].attributes.MediaId;
   photo.txtTipo03.text = this.firstChild.childNodes[2].attributes.tipo;
   photo.txtTitulo03.text = this.firstChild.childNodes[2].attributes.titulo;
   photo.txtDescripcion03.text = this.firstChild.childNodes[2].attributes.descripcion;
   photo.img03.loadMovie(this.firstChild.childNodes[2].attributes.thmb);


   photo.txtMediaId4.text = this.firstChild.childNodes[3].attributes.MediaId;
   photo.txtTipo04.text = this.firstChild.childNodes[3].attributes.tipo;
   photo.txtTitulo04.text = this.firstChild.childNodes[3].attributes.titulo;
   photo.txtDescripcion04.text = this.firstChild.childNodes[3].attributes.descripcion;
   photo.img04.loadMovie(this.firstChild.childNodes[3].attributes.thmb);


   photo.txtMediaId5.text = this.firstChild.childNodes[4].attributes.MediaId;
   photo.txtTipo05.text = this.firstChild.childNodes[4].attributes.tipo;
   photo.txtTitulo05.text = this.firstChild.childNodes[4].attributes.titulo;
   photo.txtDescripcion05.text = this.firstChild.childNodes[4].attributes.descripcion;
   photo.img05.loadMovie(this.firstChild.childNodes[4].attributes.thmb);
   //
   //for (i=0; i<numimages; i++) {
   //this.picHolder = this.firstChild.childNodes[i];
   //
   //
   //}
};
myPhoto.load("xml_scroll_central.xml");


Pueden ver que intente 2 formas (y hasta 3) de llamar al enlace, pero nada de nada. Espero que puedan ayudarme.

Por julfit0

45 de clabLevel



 

msie7
Citar            
MensajeEscrito el 07 Ago 2008 03:39 pm
Lo mejor es que hagas un ciclo hasta la cantidad de elementos del XML y des todas las acciones desde él, asi no tendrás que escribir las mismas líneas de código repetidas.

Según lo que pones, estás tratando de abrir los links con esta instrucción:

Código :

link = "http://"+this.firstChild.childNodes[0].attributes.lnk;


esto se traduciría en el caso del item 1 en:

http://http://www.yahoo.es

Además cuando pones lo siguiente, estás poniendo corchetes de más:

Código :

photo.btn1.onPress = function() {

      {

         link = "http://"+this.firstChild.childNodes[0].attributes.lnk;

         getURL(link, "_blank");

      };

   };


Debe ser:

Código :

photo.btn1.onPress = function() {

         link = "http://"+this.firstChild.childNodes[0].attributes.lnk;

         getURL(link, "_blank");

};


Y por último cuando programas dentro de la función del botón, "this" se refiere al botón en si, por lo que estás diciendole que:

Código :

link = "http://"+photo.btn1.firstChild.childNodes[0].attributes.lnk;


Y lo anterior va a resultar indefinido porque no existe

Por elchininet

Claber

3921 de clabLevel

17 tutoriales

Genero:Masculino  

Front-end developer at Booking.com

firefox
Citar            
MensajeEscrito el 07 Ago 2008 04:01 pm
Hola chininet. Primero q todo gracias por el apoyo. Dime, no logro entender bien los ultimos tips. Entiendo bien lo de los corchetes, se me paso. Entiendo tambien sobre hacer un ciclo, sin embargo no lo aplico pues aun soy novato y aun aplico repeticion de codigo, en fin, te decia que no entendia muy bien los ultimos tips.

Me dices algo sobre este boton:

Código :

photo.btn1.onPress = function() {         link = "http://"+this.firstChild.childNodes[0].attributes.lnk;         getURL(link, "_blank");};


Y por último cuando programas dentro de la función del botón, "this" se refiere al botón en si, por lo que estás diciendole que:


Código :

link = "http://"+photo.btn1.firstChild.childNodes[0].attributes.lnk;


Y lo anterior va a resultar indefinido porque no existe


No entiendo si es que en ves de "this" debo poner "photo.btn1...." o que simplemente esa linea esta mal hecha.
Lo digo porque si, me sale undefined o indefinido, es mas, no mostraba nada en el navegador.

Intentando llege a este punto, donde como comprenderas, me trave de nuevo, en el boton puse este codigo definiendo una variable:

Código :

var link:String = "";
   link += "http://"+this.firstChild.childNodes[0].attributes.lnk;
   //link += link.substr(0, 9);
   trace(link.substr(9, 30));

   photo.btn1.onRelease = function() {

      //link = "http://"+this.firstChild.childNodes[0].attributes.lnk;
      getURL(link, "_blank");
      //trace(link.substr(0, 9));

   };


Como te das cuenta sigo manteniendo el "this" y ademas estoy mostrando el bendito undefined (el cual, en vano trato de sacar). No se si sera mucha molestia para ti, pero quisiera saber si me puedes definir bien que estoy haciendo mal.

Gracias por la ayuda, de verdad me bienes ayudando mucho.

Por julfit0

45 de clabLevel



 

msie7
Citar            
MensajeEscrito el 07 Ago 2008 04:09 pm
Mmm, bueno, creo que ya vi el error en este bendito boton. Ya esta resuelto. Tenia algunas cositas demas. :crap:

Puse esto y corrio de lo mas normal, vaya que me hizo sufrir:

Código :

   var link:String = "";
   link = this.firstChild.childNodes[0].attributes.lnk;

   photo.btn1.onRelease = function() {
      getURL(link, "_blank");
   };


Chininet, muchas gracias por tu respuesta. :)

Por julfit0

45 de clabLevel



 

msie7
Citar            
MensajeEscrito el 07 Ago 2008 04:19 pm
Mira para que comprendas el uso the this, en el siguiente caso:

Código :

myPhoto.onLoad = function(success):Void {

    trace(this);

}


Lo que pasará es que cuando se lea el XML se hará un trace del XML en si, porque como this está dentro del scope de la función del onLoad del XML, se está refiriendo e este en si mimso.

Ahora cuando pones lo siguiente:

Código :

myPhoto.onLoad = function(success):Void {

    photo.btn1.onPress = function():Void {

        trace(this);

    }

}


Verás que el trace te dará como resultado algo parecido a esto:

Código :

_level0.photo.btn1


Porque ya el this no está en el scope de la función del onLoad, sino en el de la función del onPress del botón "btn1" por lo que se va a referir a este, entonces cuando le dices:

Código :

 link = "http://"+this.firstChild.childNodes[0].attributes.lnk;


Sería lo mismo que decir:

Código :

link = "http://"+level0.photo.btn1.firstChild.childNodes[0].attributes.lnk;


Y como btn1 es un botón no puede tener firstChild, ni childNodes ni ninguna de las propiedades de un XML por lo que te dará undefined. Lo correcto es que dijeras:

Código :

link = myPhoto.firstChild.childNodes[0].attributes.lnk;


Y te vuelvo a decir que no debes ponerle el http// porque si no estarías diciendo que te abriera la página http://http://www.yahoo.es

Trata de abrirla a ver si te lleva a algún lado

Por elchininet

Claber

3921 de clabLevel

17 tutoriales

Genero:Masculino  

Front-end developer at Booking.com

firefox
Citar            
MensajeEscrito el 07 Ago 2008 04:43 pm
Gracias maestro :wink:
No sabes de verdad cuanto has ayudado :)

Por julfit0

45 de clabLevel



 

msie7
Citar            
MensajeEscrito el 07 Ago 2008 07:50 pm
De nada :wink:

Por elchininet

Claber

3921 de clabLevel

17 tutoriales

Genero:Masculino  

Front-end developer at Booking.com

firefox

 

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