cs_jussy
Messages postés2Date d'inscriptionlundi 14 décembre 2009StatutMembreDernière intervention 6 janvier 2010
-
6 janv. 2010 à 12:17
cs_bali_balo
Messages postés1378Date d'inscriptionsamedi 9 octobre 2004StatutMembreDernière intervention 1 novembre 2010
-
6 janv. 2010 à 15:17
Bonjour a tous et tout d'abord bonne année!
Je suis nouveau ici et je galère pas mal avec flash en xml, j'ai recupéré un fichier fla avec un xml, j'ai reussi à la réadapter pour mon usage seulement il s'agit d'un système de diapo qui lorsque l'on clic dessus se zoom et défilent. Seulement les catégories défilent une a une avec une seule photo pas thème. Je m'explique, il y a la catégorie, par exemple architecture dans laquelle se trouve des diapos représentants les projets seulement pour chaque diapo je ne peut mettre qu'une seule image je n'arrive pas a trouver dans le xml la ligne de code pour changer ce nombre d'image..
Si quelqu'un pourrais m'aider ca serai vraiment sympa, je voudrais juste avoir plusieurs images par projets représenté par des diapos se trouvant dans des catégories, archi, archi intérieure etc..
Structure du flash:
accueil avec catégories représentée par des thumbs
on clic sur une catégorie et la thumbs des projets, on clic sur le thumb d'un projet la photo s'agrandit et on passe automatiquement au projet suivant! c'est ici que ca coince j'aimerais pouvoir mettre plusieurs images par projets...
Merci pour votre aide voici le code..
/*
Image Gallery V1.0
* Please keep this information intact
* Please feel free to modify the script and the look of the gallery to meet your needs.
* And make sure you let me know where this gallery gets used.
*/
stop();
// include assets
#include "mc_tween2.as"
#include "xmlsa.as"
#include "timer.as"
// two views ? catView : thumbView
var viewMode = "catView"; // when page is first viewed show all the categories.
var viewRand = true; // on/off random preview
var catCol = 4; // number of columns for category
var numCatDisplay = 12; // max number of categories to show per page
var numThumbDisplay = 12; // max number of thumbnails to show per page
var catColXgap = 8; // gap between categories
var catColYgap = 180;
var dropDown = false;
var curImage = 0;
var curCat = 0;
// slideshow switch
var autoSlide = true;
// default transition speed
var defTranSpeed = 400;
catView_btn._alpha = 0;
// load the xml data
gallery = new XMLSA();
gallery.load("test04.xml");
gallery.onLoad = function(ok){
if (ok) {
parseXml();
} else {
// error branch
trace("error");
}
}
/* loading stylesheet // not being used for image gallery but can be added later
function loadCss() {
styles = new TextField.StyleSheet();
css = "styles.css";
styles.load(css);
styles.onLoad = function(loaded) {
if (loaded) {
cssLoaded = true;
} else {
cssLoaded = false;
}
parseXml();
}
}
*/
function parseXml() {
//DEBUG
//trace(gallery.dump());
myGallery = new Array();
// gallery title
galleryTitle = gallery.attributes.title;
title_txt.text = galleryTitle;
for(var i=0; i<catTotal; i++) { //looping through categories
myGallery[i] = new Array();
myGallery[i]["name"] = gallery.category[i].attributes.name;
myGallery[i]["image"] = new Array();
//trace(myGallery[i]["name"]);
var imageCount = gallery.category[i].image.length;
for(var k=0; k numCatDisplay) {
catNumPages = Math.ceil(catTotal/numCatDisplay);
} else {
// if categories are less than the limit only one page is needed
catNumPages = 1;
}
// start from first page
catPageCounter = 1;
// start from 0;
var pos = 0;
// output page status
page_txt.text = catPageCounter+" of "+catNumPages;
function enableCatViewBtn() {
catView_btn.enabled = true;
catView_btn.alphaTo(100, 1);
}
function loadDropDown() {
// if less than 7 categories, shorten the dropdown bg
if(catTotal < 8) {
// height of each category buttons
var catBtnHeight = 20+3; // include the gaps
var bgHeight = catTotal * catBtnHeight;
bgHeight += 20; //include the top padding
dropDown_mc.bg_mc.tween("_height", bgHeight, 1);
}
var temp = dropDown_mc.createEmptyMovieClip("temp", _root.getNextHighestDepth());
var i=0;
temp.onEnterFrame = function(){
if(catTotal>i){
//trace(i);
var DropDownBtn = dropDown_mc.catBtn_mc.attachMovie("dropDownBtn", "dropDownBtn_mc"+i, i);
// when user clicks on one the categories, show thumbanils of that category
DropDownBtn.total = total;
DropDownBtn.chosenCat = i;
DropDownBtn.onRelease = function() {
dropDownBtn_mc.catName_txt.text = myGallery[this.chosenCat]["name"];
activateCat(this, this.chosenCat);
viewMode = "thumbView"; // change mode to thumb view
showTnView(this.chosenCat, totalImg);
// recaculate the start position
var pos = (catPageCounter*numCatDisplay)-numCatDisplay;
//trace(pos);
// output page status
page_txt.text = catPageCounter+" of "+catNumPages;
loadCat(pos);
} else if(viewMode == "thumbView") {
// hide the dropdown if it's open
if(dropDown) {
doDropDown();
}
myImg._x = Math.round(ox + (j%xnum)*(xgap + myImg._width-4)); // subtract 9 : because of drop shadow it adds to the width of box
myImg._y = Math.round(oy + myCat._y + 25);
var totalImg = myGallery[i]["image"].length;
if(viewRand) {
//get a random number between total number of images from each categories
var RandImgNum = random(myGallery[i]["image"].length);
var CurImage = RandImgNum;
var ImgDate = myGallery[i]["image"][RandImgNum]["date"];
var ImgTitle = myGallery[i]["image"][RandImgNum]["title"];
var ImgDesc = myGallery[i]["image"][RandImgNum]["desc"];
var ImgThumb = myGallery[i]["image"][RandImgNum]["thumb"];
var ImgFull = myGallery[i]["image"][RandImgNum]["img"];
} else {
var CurImage = 0;
// 0 == most recently added image <- controlled by php
var ImgDate = myGallery[i]["image"][0]["date"];
var ImgTitle = myGallery[i]["image"][0]["title"];
var ImgDesc = myGallery[i]["image"][0]["desc"];
var ImgThumb = myGallery[i]["image"][0]["thumb"];
var ImgFull = myGallery[i]["image"][0]["img"];
}
// when user clicks on one the categories, show thumbanils of that category
myCat.total = total;
myCat.chosenCat = i;
myCat.onRelease = function() {
dropDownBtn_mc.catName_txt.text = myGallery[this.chosenCat]["name"];
activateCat(this, this.chosenCat);
viewMode = "thumbView"; // change mode to thumb view
showTnView(this.chosenCat, totalImg);
var target = this;
var imgDesc = this.imgDesc;
var thumbToLoad = this.thumbToLoad;
var imgToLoad = this.imgToLoad;
var curImage = this.curImage;
var curCat = this.curCat;
var thumbTotal = this.total;
this.loadMovie(thumbDir+thumbToLoad);
var temp = this._parent.createEmptyMovieClip("temp", this._parent.getNextHighestDepth());
temp.onEnterFrame = function() {
var loaded = target.getBytesLoaded();
var total = target.getBytesTotal();
var perc = Math.round(loaded/total*100);
// init pos and alpha of click_txt
this._parent.click_txt._alpha = 100;
//this._parent.click_txt.roundedYSlideTo(15, 0.2);
var orgWidth = this._width;
var orgHeight = this._height;
var orgX = this._x;
var orgY = this._y;
// resizeImg object is returned by resizeToFit prototype function and saved as myImage;
var myImage = this.resizeToFit();
this.tween(["_width", "_height"], [myImage.newWidth, myImage.newHeight], 1);
// slide the image to the middle point y
var yMiddle = -(Number(myImage.newHeight/2)-40);
//trace(yMiddle);
//this.ySlideTo(yMiddle, 2);
var imageBorder = 20;
var mcW = imageHolder._width;
var mcH = imageHolder._height;
//total of images in chosen category
var totalImages = myGallery[curCat]["image"].length;
curImage_txt.text = Number(_root.curImage+1)+" of "+totalImages;
enableImageNav(true);
//trace(mcW);
if(mcW > 710) {
imageHolder.maxWidth = 710;
var newSize = imageHolder.resizeToFit();
imageHolder.tween(["_width", "_height"], [newSize.newWidth, newSize.newHeight], 0.5, undefined);
var mcW = newSize.newWidth;
var mcH = newSize.newHeight;
}
var xCenter = (transBG_mc.fake_btn._width/2) - (Number(mcW+imageBorder)/2);
var yCenter = (transBG_mc.fake_btn._height/2) - (Number(mcH+imageBorder)/2);
// center the image
transBG_mc.picBG_mc.slideTo(xCenter, yCenter, 0.5);
// resize the background
transBG_mc.picBG_mc.bg_mc.tween(["_width", "_height"], [mcW+imageBorder, mcH+imageBorder], 0.5, undefined, 0, function() { });
transBG_mc.picBG_mc.bg_mc.alphaTo(100, 0.5, "linear", 0, function() { imageHolder.alphaTo(100, 2); });
var descMC = _root.transBG_mc.desc_mc;
// put description
descMC.desc_txt.text = desc;
// resize textfield
var padding = 30;
var myFormat_fmt = new TextFormat();
var textDimension = myFormat_fmt.getTextExtent(desc, 200);
var tWidth = textDimension.textFieldWidth;
var tHeight = textDimension.textFieldHeight+20; // used 20 to prevent it from text get cut off at the end //////////////////////////
// center image description mc
var xDescCenter = ((transBG_mc.fake_btn._width+imageBorder)/2) - ((descMC._width+imageBorder)/2);
var yDescCenter = ((transBG_mc.fake_btn._height+imageBorder)/2) - ((descMC._height+imageBorder)/2);
descMC.slideTo(xDescCenter, yDescCenter, 0.5);
// hide full view
exit_mc.onRelease = function() {
var DisappearW = mcW;
var DisappearH = mcH;
var DisappearXCenter = (transBG_mc.fake_btn._width/2) - (Number(DisappearW+imageBorder/2)/2);
var DisappearYCenter = (transBG_mc.fake_btn._height/2) - (Number(DisappearH+imageBorder/2)/2);
function showNextImage(imageHolder) {
//total of images in chosen category
var totalImages = myGallery[curCat]["image"].length;
if(totalImages-1 > curImage) {
_root.curImage += 1;
} else if(totalImages-1 == curImage) {
_root.curImage = 0;
}
//fade the picture out
imageHolder.alphaTo(0, 0.5, "linear");
var ImgDesc = myGallery[curCat]["image"][curImage]["desc"];
var ImgFull = myGallery[curCat]["image"][curImage]["img"];
/*
// disable thumb
var thumb = imgWrap_mc["thumb_mc"+curImage];
activateItem(thumb);*/
curImage_txt.text = Number(_root.curImage+1)+" of "+totalImages;
showFullImage(ImgFull, ImgDesc);
}
function showPrevImage(imageHolder) {
//total of images in chosen category
var totalImages = myGallery[curCat]["image"].length;
if(curImage > 0) {
_root.curImage -= 1;
} else if(curImage == 0) {
_root.curImage = totalImages-1;
}
//fade the picture out
imageHolder.alphaTo(0, 0.5, "linear");
var ImgDesc = myGallery[curCat]["image"][curImage]["desc"];
var ImgFull = myGallery[curCat]["image"][curImage]["img"];
curImage_txt.text = Number(_root.curImage+1)+" of "+totalImages;
showFullImage(ImgFull, ImgDesc);
}
function activateItem(item, oWidth, oHeight) {
// hide the dropdown if it's open
if(dropDown) {
doDropDown();
}
if (currentItem != false) {
deactivateItem();
}
currentItem = item;
/* prototype for resizing an image to defined size while keeping ratio */
/* it returns an object with new width and height */
MovieClip.prototype.resizeToFit = function (){
var pMaxWidth = this.maxWidth;
var pMaxHeight = this.maxHeight;
// determines ratio depends on the width and height
//this._width>=this._height ? ratio=pMaxWidth/this._width : ratio=pMaxHeight/this._height;
// ratio based on width
var ratio=pMaxWidth/this._width;
var resizedImg = new Object();
resizedImg.newWidth = Math.round(this._width*ratio);
resizedImg.newHeight = Math.round(this._height*ratio);
return resizedImg;
}
function showTnView(catNum, totalImg) {
viewMode = "thumbView";
curCat = catNum;
// determine the number of pages needed for viewing thumbnails
if(totalImg > numThumbDisplay) {
trace('true');
thumbNumPages = Math.ceil(totalImg/numThumbDisplay);
} else {
trace('false');
// if categories are less than the limit only one page is needed
thumbNumPages = 1;
}
// start from first page
thumbPageCounter = 1;
// start from 0;
var pos = 0;
// output page status
page_txt.text = thumbPageCounter+" of "+thumbNumPages;
hideCat();
/*
// count how many thumbnails are currently sitting inside of imgWrap_mc
var count = 0;
for(var each in imgWrap_mc) {
count++;
}
trace(count);
myImg._x = Math.round(ox + (j%xnum)*(xgap + myImg._width-4)); // subtract 9 : because of drop shadow it adds to the width of box
myImg._y = Math.round(oy + int(j/xnum)*ygap);
var ImgDate = myGallery[catNum]["image"][i]["date"];
var ImgTitle = myGallery[catNum]["image"][i]["title"];
var ImgDesc = myGallery[catNum]["image"][i]["desc"];
var ImgThumb = myGallery[catNum]["image"][i]["thumb"];
var ImgFull = myGallery[catNum]["image"][i]["img"];
cs_jussy
Messages postés2Date d'inscriptionlundi 14 décembre 2009StatutMembreDernière intervention 6 janvier 2010 6 janv. 2010 à 12:20
je crois que c'est a cet endroit mais je ne sais pas comment changer ca...
merci
//total of images in chosen category
var totalImages = myGallery[curCat]["image"].length;
curImage_txt.text = Number(_root.curImage+1)+" of "+totalImages;