Hi everyone,
Ok, I put together a pretty neat XML gallery, but I was wondering if there was anyway to change the code so that upon clicking on the thumbnail it would load the actual picture in a blank browser. like when you click on a picture in a regular html website.
I know that you can do it by manually saying getURL(http://www.bla.com, _blank); or whatever - but yeah I was wondering if you can code it to load from XML.
is this impossible?
here is the code for the gallery–
stop();
var thumb_spacing = 51;
var columns = 6;
//variable we need later if we switch galleries to remove the old thumbs
var curLength;
var description_lv = new LoadVars();
description_lv.onData = function(raw_text) {
description_txt.text = raw_text;
};
function GeneratePortfolio(portfolio_xml, d) {
//remove the old thumbs
for (var i = 0; i<curLength; i++) {
menu_mc["thumbnail_mc"+i].removeMovieClip();
}
//unload the last big picture
image_mc.unloadMovie();
var portfolioPictures = portfolio_xml.firstChild.childNodes[d].childNodes;
galleryInfo.text = portfolio_xml.firstChild.childNodes[d].attributes.title;
for (var i = 0; i<portfolioPictures.length; i++) {
var currentPicture = portfolioPictures*;
var currentThumb_mc = menu_mc.createEmptyMovieClip("thumbnail_mc"+i, i);
currentThumb_mc._x = (i%columns)*thumb_spacing;
currentThumb_mc._y = Math.floor(i/columns)*thumb_spacing;
currentThumb_mc.createEmptyMovieClip("thumb_container", 0);
currentThumb_mc.thumb_container.loadMovie(currentPicture.attributes.thumb);
currentThumb_mc.title = currentPicture.attributes.title;
currentThumb_mc.image = currentPicture.attributes.image;
currentThumb_mc.description = currentPicture.attributes.description;
currentThumb_mc.onRollOver = currentThumb_mc.onDragOver=function () {
info_txt.text = this.title;
};
currentThumb_mc.onRollOut = currentThumb_mc.onDragOut=function () {
info_txt.text = "";
};
currentThumb_mc.onRelease = function() {
loadPic(this.image);
description_lv.load(this.description);
};
}
//set curLength
curLength = portfolioPictures.length;
}
function loadPic(pic) {
image_mc.loadMovie(pic);
var temp = this.createEmptyMovieClip("tmp", 9999);
temp.onEnterFrame = function() {
var t = image_mc.getBytesTotal();
var l = image_mc.getBytesLoaded();
if (t == l && t>4) {
delete this.onEnterFrame;
}
};
}
//function to choose a gallery
function galleryChoice(d) {
var portfolio_xml = new XML();
portfolio_xml.ignoreWhite = true;
portfolio_xml.onLoad = function(success) {
if (success) {
GeneratePortfolio(this, d);
} else {
trace("Error loading XML file");
}
// no success? trace error (wont be seen on web)
};
portfolio_xml.load("portfolio.xml");
}
//start with first gallery
galleryChoice(0);
//buttons to choose a new gallery
but1.onRelease = function() {
galleryChoice(0);
};
but2.onRelease = function() {
galleryChoice(1);
};
and if you really wana see what the gallery looks like now - Click here
Thanks in advance for any help !!!