Además pongo el código de Javascript que se necesita para conectar Flash con Lightbox.
Me he basado en la información de este sitio y me ha servidio muchisimo, ya que consigo ejecutar el Lightbox si no hago uso para nada del XML, es decir, tal y como viene en el tutorial de este enlace:
http://blog.codefidelity.com/?p=16
Os copio los codigos que tengo hasta ahora.
Estos son los script que van en el html:
Código Javascript :
<script src="js/prototype.js" type="text/javascript"></script>
<script src="js/scriptaculous.js?load=effects" type="text/javascript"></script>
<script src="js/lightbox++.js" type="text/javascript"></script>
<script type="text/javascript">
function LightboxDelegate(url,caption) {
var objLink = document.createElement('a');
objLink.setAttribute('href',url);
objLink.setAttribute('rel','lightbox');
objLink.setAttribute('title',caption);
Lightbox.prototype.start(objLink);
}
</script>
Dentro del object de flash tienen que estar las siguientes propiedades:
<param name="wmode" value="transparent">
<param name="allowscriptaccess" value="samedomain">
El XML
Código XML :
<?xml version="2.0" encoding="ISO-8859-2"?>
<botones>
<item name="Producto n1" url="javascript:LightboxDelegate('green_enl.jpg','Green Wallpaper')" image="image1.jpg" />
<item name="Producto n2" url="javascript:LightboxDelegate('orange_enl.jpg','Orange Wallpaper')" image="image2.jpg" />
<item name="Producto n3" url="javascript:LightboxDelegate('blue_enl.jpg','Blue Wallpaper')" image="image3.jpg" />
</botones>
Por último el Action Scritp:
Código ActionScript :
var myMenu:XML = new XML();
myMenu.ignoreWhite = true;
System.useCodepage = true;
myMenu.load("enlaces.xml");
linkBoton = new Array();
textoBoton = new Array();
imageBoton = new Array();
myMenu.onLoad = function() {
for (var i = 0; i<this.firstChild.childNodes.length; i++) {
textoBoton[i] = this.firstChild.childNodes[i].attributes.name;
linkBoton[i] = this.firstChild.childNodes[i].attributes.url;
imageBoton[i] = this.firstChild.childNodes[i].attributes.image;
}
creaBtns(this.firstChild.childNodes.length);
};
function creaBtns(cuantosBotones) {
var filas = 4;
var columnas = 2;
alturaY = 10;//posY en stage
alturaX = 10;//posX en stage
var xOffset = 295 //10 de separaciónX
var yOffset = 130 //10 de separaciónY
var depth = 0;
count = 0;
for (var f = 0; f<filas; f++) {
for (var c = 0; c<columnas; c++) {
target = this.attachMovie("boton", "boton"+depth, depth++, {_x: c*xOffset, _y: f*yOffset});
target.image_mc.loadMovie(imageBoton[depth-1]);
target.url = linkBoton[depth-1];
target.mytexto.text = textoBoton[depth-1];
target.onRelease = function() {
getURL("javascript:LightboxDelegate('linkBoton[depth-1]', '');", "_self");
};
if(++count>=cuantosBotones) return;
}
}
}
Si os fijais, en la línea importante, la de getURL("java.......); al final he puesto "_self", viendo documentacion en esta web, pone que hay que usar el atributo target="_self"...he probado a ponerlo en el action script y no me funciona...y en el XML y tampoco, es posible que sea por eso por lo que no me funcione, pero no lo estoy colocando bien y he hecho mil pruebas y sigue sin funcionar.
Con todo esto casi lo consigo, porque hago click en la imagen en miniatura que carga el XML y me salta el cuadro blanco con el loading del Lightbox...pero no aparece la imagen en grande!! Me falta un pelo pero nose lo que es
Muchas gracias
Rocha
