Bonjour tout le monde,
un petit problème avec un tuto que j'ai choppé je ne sais plus où.
il s'agit de réaliser une gallerie photo.
j'essaie de modifier le code afin que l'image puisse se redimensionner selon la taille du cadre choisi.
est ce que quelqu'un voit ce qui ne va pas?
merci d'avance.
le code :
var tnNr;
spacing = 10;
container._alpha = 0;
var curLength;
screenh = 380;// dimension cadre
screenw = 380;
MovieClip.prototype.loadPic = function(pic, id) {
info.text = "";
this._alpha = 0;
this.loadMovie(pic);
temp = this._parent.createEmptyMovieClip("temp2", 998);
temp.onEnterFrame = function() {
var t = container.getBytesTotal(), l = container.getBytesLoaded();
if (Math.round(l/t) == 1 && container._width != 0 && container._height != 0) {
var w = container._width+spacing, h = container._height+spacing;
border.resizeMe(w, h, id);
delete this.onEnterFrame;
}
};
};
MovieClip.prototype.resizeMe = function(w, h, id) {
var speed = 3;
container._alpha = 0;
this.onEnterFrame = function() {
this._width += (w-this._width)/speed;
this._height += (h-this._height)/speed;
// vaine tentative de redimensionnement////////////////////////
var ratio = (w)/(h);
if (w>screenw) {
while (w>screenw) {
w-= 1;
}
h = w/ratio;
}
if(h>screenh) {
while (h>screenh) {
h -= 1;
}
w = h*ratio;
}
// fin//////////////////
if (Math.abs(this._width-w)<1 && Math.abs(this._height-h)<1) {
this._width = w;
this._height = h;
container._x = this._x-this._width/2+spacing/2;
container._y = this._y-this._height/2+spacing/2;
info._y = Math.round(this._y+this._height/2+spacing/2);
container._alpha += 5;
if (container._alpha>90) {
info.text = id;
container._alpha = 100;
delete this.onEnterFrame;
}
}
};
};
function galleryChoice(q) {
pArray = new Array();
tArray = new Array();
iArray = new Array();
my_xml = new XML();
for (var j = 0; j
4) {
nextButton();
delete this.onEnterFrame;
}
};
}
function nextButton() {
if (tnNr