Comunidad de diseño web y desarrollo en internet online

Ayuda texto descripción Galeria xml

Citar            
MensajeEscrito el 29 Sep 2008 09:41 am
Hola, estoy adaptando la galería xml que me bajé de Kirupa y tengo un problemilla con el texto de descripción de cada foto. Ahora aparece al hacer clic en cada foto pero necesitaría que apareciera al pasar el ratón por encima. La cosa se complica porque este es un swf que carga dinámicamente en otra galería (otro swf) por eso la ruta de la caja de texto es esta

Código :

_level0.picture.desc_txt.text = description[p];

Seguro que es una tontería pero no consigo cambiarlo. Si me pudiérais ayudar.... muchas gracias de antemano.
El código Actionscript es este:

Código :

stop();
function loadXML(loaded) {
   if (loaded) {
      xmlNode = this.firstChild;
      thumbnails = [];
      description = [];
      total = xmlNode.childNodes.length;
      for (i=0; i<total; i++) {
         description[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
         thumbnails[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
         
         thumbnails_fn(i); 
      }
      firstImage();
   } else {
      content = "file not loaded!";
   }
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("edificacion/gran/images1.xml");
///////////////////////////////////// 
listen = new Object();
listen.onKeyDown = function() {
   if (Key.getCode() == Key.LEFT) {
      prevImage();
   } else if (Key.getCode() == Key.RIGHT) {
      nextImage();
   }
};
Key.addListener(listen);
previous_btn.onRelease = function() {
   prevImage();
};
next_btn.onRelease = function() {
   nextImage();
};
///////////////////////////////////// 
p = 0;
this.onEnterFrame = function() {
   filesize = picture.getBytesTotal();
   loaded = picture.getBytesLoaded();
   preloader._visible = true;
   if (loaded != filesize) {
      preloader.preload_bar._xscale = 100*loaded/filesize;
   } else {
      preloader._visible = false;
      if (picture._alpha<100) {
         picture._alpha += 10;
      }
   }
};
function nextImage() {
   if (p<(total-1)) {
      p++;
      if (loaded == filesize) {
         picture._alpha = 0;
         picture.loadMovie(image[p], 1);
         _level0.picture.desc_txt.text = description[p];
         picture_num();
      }
   }
}
function prevImage() {
   if (p>0) {
      p--;
      picture._alpha = 0;
      picture.loadMovie(image[p], 1);
      _level0.picture.desc_txt.text = description[p];
      picture_num();
   }
}

function firstImage() {
   if (loaded == filesize) {
      picture._alpha = 0;
      picture.loadMovie(image[0], 1);
      _level0.picture.desc_txt.text = description[0];
      picture_num();
   }
}

function picture_num() {
   current_pos = p+1;
   _level0.picture.pos_txt.text = current_pos+" / "+total;
}
function thumbNailScroller() {
   // thumbnail code! 
   this.createEmptyMovieClip("tscroller", 1000);
   scroll_speed = 20;
   tscroller.onEnterFrame = function() {
      if ((_root._ymouse>=thumbnail_mc._y) && (_root._ymouse<=thumbnail_mc._y+thumbnail_mc._height)) {
         if ((_root._xmouse>=(hit_right._x-40)) && (thumbnail_mc.hitTest(hit_right))) {
            thumbnail_mc._x -= scroll_speed;
         } else if ((_root._xmouse<=(hit_left._x+200)) && (thumbnail_mc.hitTest(hit_left))) {
            thumbnail_mc._x += scroll_speed;
         }
      } else {
         delete tscroller.onEnterFrame;
      }
   };
}
function thumbnails_fn(k) {
   thumbnail_mc.createEmptyMovieClip("t"+k, thumbnail_mc.getNextHighestDepth());
   tlistener = new Object();
   tlistener.onLoadInit = function(target_mc) {
      target_mc._x = hit_left._x+(target_mc._width+5)*k;
      target_mc.pictureValue = k;
      target_mc.onRollOver = function() {
         p = this.pictureValue-1;
         nextImage();
      };
      target_mc.onRollOver = function() {
         //this._alpha = 50;
         thumbNailScroller();
      };
      //target_mc.onRollOut = function() {
         //this._alpha = 100;
      //};
   };
   image_mcl = new MovieClipLoader();
   image_mcl.addListener(tlistener);
   image_mcl.loadClip(thumbnails[k], "thumbnail_mc.t"+k);
}


El xml es este

Código :

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<images>
    <pic>
      
        <caption>primera descripcion</caption>
        <thumbnail>edificacion/gran/1/a.jpg</thumbnail>
    </pic>
   <pic>
    
        <caption>segunda descripcion</caption>
        <thumbnail>edificacion/gran/1/b.jpg</thumbnail>
    </pic>
   <pic>
   
        <caption>tercera descripcion</caption>
        <thumbnail>edificacion/gran/1/c.jpg</thumbnail>
        
    </pic>
   

   
    
</images>

Por lamarula

7 de clabLevel



 

safari
Citar            
MensajeEscrito el 29 Sep 2008 08:48 pm
Tienes la función de onRollOver creada: (Ojo la tienes duplicada, deja una sola)

Código ActionScript :

target_mc.onRollOver = function() {
         p = this.pictureValue-1;
         nextImage();
 };

target_mc.onRollOver = function() {
         //this._alpha = 50;
         thumbNailScroller();
};


Y dentro de la función nextImage y prevImage cambias el texto:

Código ActionScript :

_level0.picture.desc_txt.text = description[p];


Por lo tanto si situas esa línea dentro de la función debería funcionar:

Código ActionScript :

target_mc.onRollOver = function() {
         p = this.pictureValue-1;
         _level0.picture.desc_txt.text = description[p];
         thumbNailScroller();
 };

Por elchininet

Claber

3921 de clabLevel

17 tutoriales

Genero:Masculino  

Front-end developer at Booking.com

firefox
Citar            
MensajeEscrito el 30 Sep 2008 09:53 am
Muchas gracias!!! Lo he probado como me decías y, al principio no me funcionaba, pero he investigado un poco más y me he dado cuenta de que si metía esa línea (la que llama al texto de descripción) dentro de la función también tenía que meter la línea que llama a la caja de texto de orden de las imágenes:

Código :

_level0.picture.pos_txt.text = current_pos+" / "+total;


Así que esa parte del código queda así y funciona perfectamente

Código :

function thumbnails_fn(k) {
   thumbnail_mc.createEmptyMovieClip("t"+k,thumbnail_mc.getNextHighestDepth());
   tlistener = new Object();
   tlistener.onLoadInit = function(target_mc) {
      target_mc._x = hit_left._x+(target_mc._width+5)*k;
      target_mc.pictureValue = k;
      target_mc.onRollOver = function() {
         p = this.pictureValue-1;
         _level0.picture.desc_txt.text = description[p];
         nextImage();
         this._alpha = 50;
         thumbNailScroller();
         current_pos = p+1;
         _level0.picture.pos_txt.text = current_pos+" / "+total;
      };


      target_mc.onRollOut = function() {
         _level0.picture.desc_txt.text = description[p];
         _level0.picture.pos_txt.text = current_pos+" / "+total;
         this._alpha = 100;
      };


Otra cosilla que querría hacer ahora es que al pinchar en las imágenes se abra un pdf en ventana nueva. Lo he intentado añadiendo este código dentro de esa misma función

Código :

target_mc.onRelease = function() {
         getPdf();

y este otro fuera

[code]function getPdf() {
      getURL(pdf[p++]);
   }[/code]
      };


El caso es que me funciona pero debe de haber un error en lo de
pdf[p++]
por que me abre los enlaces a los pdf que tengo en el XML uno tras otro secuencialmente y no el pdf que corresponde a la imagen cargada en la que hago clic.
El XML es este:

Código :

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<images>
    <pic>
         <pdf>urbanismo/gran/1/plano1.pdf</pdf>
      <caption>Primera descripcion</caption>
        <thumbnail>urbanismo/gran/1/a.jpg</thumbnail>
    </pic>
   <pic>
        <pdf>urbanismo/gran/1/plano2.pdf</pdf>
        <caption>Segunda descripcion</caption>
        <thumbnail>urbanismo/gran/1/b.jpg</thumbnail>
    </pic>
   <pic>
         <pdf>urbanismo/gran/1/plano3.pdf</pdf>
        <caption>Segunda descripcion</caption>
        <thumbnail>urbanismo/gran/1/c.jpg</thumbnail>
        
    </pic>
    
</images>


Muuuuchas graciaaaaas!

Por lamarula

7 de clabLevel



 

safari
Citar            
MensajeEscrito el 30 Sep 2008 10:59 am
No pongas el nodo del <pdf> de primero porque el código que tenías guarda el primer y el segundo nodo como "descripcion" y "thumbnails", deja tu XML así:

Código XML :

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<images>
   <pic>
      <caption>Primera descripcion</caption>
      <thumbnail>urbanismo/gran/1/a.jpg</thumbnail>
      <pdf>urbanismo/gran/1/plano1.pdf</pdf>
   </pic>
   <pic>
      <caption>Segunda descripcion</caption>
      <thumbnail>urbanismo/gran/1/b.jpg</thumbnail>
      <pdf>urbanismo/gran/1/plano2.pdf</pdf>
   </pic>
   <pic>
      <caption>Segunda descripcion</caption>
      <thumbnail>urbanismo/gran/1/c.jpg</thumbnail>
      <pdf>urbanismo/gran/1/plano3.pdf</pdf>
   </pic>
</images>


Después guarda los nodos de pdf en un arreglo igual que los anteriores:

Código ActionScript :

thumbnails = [];
description = [];
pdf = [];
total = xmlNode.childNodes.length;
for (i = 0; i < total; i++) {
   description[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
   thumbnails[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
   pdf[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;


Y depués puedes acceder a ese valor desde el onRelease:

Código ActionScript :

target_mc.onRelease = function():Void{
   
   p = this.pictureValue-1;
   getURL(pdf[p], "_blank");
   
}

Por elchininet

Claber

3921 de clabLevel

17 tutoriales

Genero:Masculino  

Front-end developer at Booking.com

firefox
Citar            
MensajeEscrito el 30 Sep 2008 02:27 pm
muchas gracias!!! ya lo tengo, pero he hecho unos cambios porque con el código que me decías me daba error de sintaxis. Le he quitado lo de :Void y ahora si me funciona... pero me queda la duda ¿para que sirve :Void? ¿Qué significa?
También le he quitado el -1 porque si lo dejeba en el primero no me abría ninguno, en el segundo el primero, y así sucesivamente. Ha quedado así

Código :

target_mc.onRelease = function() { 
       p = this.pictureValue; 
         getURL(pdf[p]);
      };

Lo dicho. Muchas gracias.

Por lamarula

7 de clabLevel



 

safari
Citar            
MensajeEscrito el 30 Sep 2008 09:59 pm
Void quiere decir que la función no devuelve ningún valor y si te da error es síntoma de que estás trabajando con AS1 y el código que te he facilitado es para AS2.

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.