Тема: lightbox2 + flash
Показать сообщение отдельно
Старый 12.07.2008, 01:35
intrdr вне форума Посмотреть профиль Отправить личное сообщение для intrdr Найти все сообщения от intrdr
  № 2  
Ответить с цитированием
intrdr

Регистрация: Feb 2008
Сообщений: 47
Нашел такой пример:

Код:
Here's the start() function, located on line 389 of lightbox.js:

...
//
// start()
// Display overlay and lightbox. If image is part of a set, add siblings to imageArray.
//
start: function(imageLink) {

hideSelectBoxes();
hideFlash();

// stretch overlay to fill page and fade in
var arrayPageSize = getPageSize();
Element.setWidth('overlay', arrayPageSize[0]);
Element.setHeight('overlay', arrayPageSize[1]);

new Effect.Appear('overlay', { duration: overlayDuration, from: 0.0, to: overlayOpacity });

imageArray = [];
imageNum = 0;

if (!document.getElementsByTagName){ return; }
var anchors = document.getElementsByTagName( imageLink.tagName);

// if image is NOT part of a set..
if((imageLink.getAttribute('rel') == 'lightbox')){
// add single image to imageArray
imageArray.push(new Array(imageLink.getAttribute('href'), imageLink.getAttribute('title')));
} else {
// if image is part of a set..

// loop through anchors, find other images in set, and add them to imageArray
for (var i=0; i<anchors.length; i++){
var anchor = anchors[i];
if (anchor.getAttribute('href') && (anchor.getAttribute('rel') == imageLink.getAttribute('rel'))){
imageArray.push(new Array(anchor.getAttribute('href'), anchor.getAttribute('title')));
}
}
imageArray.removeDuplicates();
while(imageArray[imageNum][0] != imageLink.getAttribute('href')) { imageNum++;}
}

// calculate top and left offset for the lightbox
var arrayPageScroll = getPageScroll();
var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] / 10);
var lightboxLeft = arrayPageScroll[0];
Element.setTop('lightbox', lightboxTop);
Element.setLeft('lightbox', lightboxLeft);

Element.show('lightbox');

this.changeImage(imageNum);
},
...


In the end, you could modify the function to accept additional parameters instead of getting them from the html, then call it from your own custom function (say it's "createLightbox") that would allow you to pass these paramaters and establish any other settings you needed.

Something like this is what I'd imagine:

function createLightbox(imgpath,caption,group){
lightboxObj = new Lightbox();
//assign any parameters here...
lightboxObj.start(imgpath,caption,group);
}


Then you'd simply call this javascript function using a getURL statement in flash:

my_mc.onRelease = function(){
getURL("javascript:createLightbox('images/mypic.jpg','Some friends of mine','roadtrip');","_self");
}
Но не работает.

У кого-то получилось реализовать что-то подобное?