Hi guys !
I’m currently building an XML generated portfolio website.
On the main screen is, on the right, thumbnails to select which particular project you want to view… so far, so good. For every project, a certain amount of pictures can be seen, and more thumbnails need to be added to view these pictures. A maximum of 4 thumbnails per project can be uploaded.
Now here’s the problem: Let’s say I want to hide thumbnail #4. I used an attribute called “condition” which I set to “on” or “off”, and an “if” statement to tell Flash to hide or show one particular thumbnail. Using the script provided below, thumbnail #4 is in fact hidden, but for ALL projects. So here is the script:
var thumbspacing = 62;
thumb1btn_mc._visible = false;
thumb2btn_mc._visible = false;
thumb3btn_mc._visible = false;
thumb4btn_mc._visible = false;
function triggerProject (){
main_image_container_mc.loadMovie(this.image);
text_mc.titre_txt.text = this.titre_texte;
text_mc.client_txt.text = this.client_texte;
text_mc.details_txt.text = this.details_texte;
image1_container_mc.loadMovie(this.imageUn);
image2_container_mc.loadMovie(this.imageDeux);
image3_container_mc.loadMovie(this.imageTrois);
image4_container_mc.loadMovie(this.imageQuatre);
thumb1_mc.loadMovie(this.thumbUn);
thumb1btn_mc._visible = true;
thumb2_mc.loadMovie(this.thumbDeux);
thumb2btn_mc._visible = true;
thumb3_mc.loadMovie(this.thumbTrois);
thumb3btn_mc._visible = true;
//SO HERE'S WHAT I TRIED... just on thumb #4 for now...
if (thumb4.attributes.condition == "on"){
thumb4_mc.loadMovie(this.thumbQuatre);
thumb4btn_mc._visible = true;
}
}
function showImage1 (){
image1_container_mc._visible = true;
image2_container_mc._visible = false;
image3_container_mc._visible = false;
image4_container_mc._visible = false;
}
function showImage2 (){
image1_container_mc._visible = false;
image2_container_mc._visible = true;
image3_container_mc._visible = false;
image4_container_mc._visible = false;
}
function showImage3 (){
image1_container_mc._visible = false;
image2_container_mc._visible = false;
image3_container_mc._visible = true;
image4_container_mc._visible = false;
}
function showImage4 (){
image1_container_mc._visible = false;
image2_container_mc._visible = false;
image3_container_mc._visible = false;
image4_container_mc._visible = true;
}
function GeneratePortfolio(portfolio_xml) {
var projects = portfolio_xml.firstChild.firstChild.childNodes;
for (var i = 0; i<projects.length; i++) {
var thumb = projects*.firstChild;
var titre = projects*.childNodes[2];
var client = projects*.childNodes[3];
var details = projects*.childNodes[4];
var thumb1 = projects*.childNodes[5];
var thumb2 = projects*.childNodes[6];
var thumb3 = projects*.childNodes[7];
var thumb4 = projects*.childNodes[8];
var image1 = projects*.childNodes[9];
var image2 = projects*.childNodes[10];
var image3 = projects*.childNodes[11];
var image4 = projects*.childNodes[12];
//thumbs principaux
var thumb_btn_mc = scroller_mc.allthumbsbtn_mc.attachMovie("thumb_btn_mc", "thumb_btn"+i, i);
thumb_btn_mc._y = i * thumbspacing;
var thumb_mc = scroller_mc.allthumbs_mc.attachMovie("thumb_container", "thumb"+i, i);
thumb_mc.loadMovie(thumb.firstChild);
thumb_mc._y = i * thumbspacing;
//thumbs et images de chaque projet...
var thumb1_mc = thumb1_mc.attachMovie("thumb1", "thumb1"+i, i);
var thumb1_btn = thumb1btn_mc.attachMovie("thumb_btn_mc", "thumb1btn"+i,i);
var thumb2_mc = thumb2_mc.attachMovie("thumb1", "thumb2"+i, i);
var thumb2_btn = thumb2btn_mc.attachMovie("thumb_btn_mc", "thumb2btn"+i,i);
var thumb3_mc = thumb3_mc.attachMovie("thumb1", "thumb3"+i, i);
var thumb3_btn = thumb3btn_mc.attachMovie("thumb_btn_mc", "thumb3btn"+i,i);
var thumb4_mc = thumb4_mc.attachMovie("thumb1", "thumb4"+i, i);
var thumb4_btn = thumb4btn_mc.attachMovie("thumb_btn_mc", "thumb4btn"+i,i);
var image1_mc = image1_container_mc.attachMovie("image", "image1"+i, i);
var image2_mc = image2_container_mc.attachMovie("image", "image2"+i, i);
var image3_mc = image3_container_mc.attachMovie("image", "image3"+i, i);
var image4_mc = image4_container_mc.attachMovie("image", "image4"+i, i);
//trace (thumb2.attributes.condition);
thumb_btn_mc.thumb_btn.image = projects*.childNodes[1].attributes.image;
thumb_btn_mc.thumb_btn.titre_texte = titre.firstChild.nodeValue;
thumb_btn_mc.thumb_btn.client_texte = client.firstChild.nodeValue;
thumb_btn_mc.thumb_btn.details_texte = details.firstChild.nodeValue;
thumb_btn_mc.thumb_btn.thumbUn = thumb1.firstChild.nodeValue;
thumb_btn_mc.thumb_btn.thumbDeux = thumb2.firstChild.nodeValue;
thumb_btn_mc.thumb_btn.thumbTrois = thumb3.firstChild.nodeValue;
thumb_btn_mc.thumb_btn.thumbQuatre = thumb4.firstChild.nodeValue;
thumb_btn_mc.thumb_btn.imageUn = image1.attributes.image;
thumb_btn_mc.thumb_btn.imageDeux = image2.attributes.image;
thumb_btn_mc.thumb_btn.imageTrois = image3.attributes.image;
thumb_btn_mc.thumb_btn.imageQuatre = image4.attributes.image;
//onRealease... thumbs principaux
thumb_btn_mc.thumb_btn.onRelease = triggerProject;
//onRelease... thumbs du projet
thumb1_btn.onRelease = showImage1;
thumb2_btn.onRelease = showImage2;
thumb3_btn.onRelease = showImage3;
thumb4_btn.onRelease = showImage4;
}
}
var portfolio_xml = new XML();
portfolio_xml.ignoreWhite = true;
portfolio_xml.onLoad = function(success) {
if (success) {
GeneratePortfolio(this);
} else {
trace("Error loading XML file");
}
};
portfolio_xml.load("case.xml");
I don’t get it ! Isn’t the function “triggerProject” supposed to be different everytime it is called by the onRelease action ?
By the way… sorry if this code’s a bit messy. It’s the first time I’ve written one by myself.
Thanx for your help guys !