ho un documento, (una gallery fotografica):
lo script e' questo, un po lungo ma DISCRETAMENTE semplice, funziona tutto ma se faccio caricare questo file esternamete in un nuovo lavoro, dentro un MC istanziato images, non funziona qualcosa, per esempio il caricamento delle immagini, aiutatemi a sistemare i percorsi.
sfondo._alpha = 0;
name_photo = new LoadVars();
name_photo.onLoad = function(success) {
if (success) {
_level0.prefix = this.name;
_level0.ID_MAX = this.total;
_level0.go();
}
};
name_photo.load("parametriamici.txt");
W_box = H_box=60;
W_box_pic = H_box_pic=50;
Space_box = 3;
mask.swapDepths(100);
mask._x = 290;
mask._y = 570;
this.createEmptyMovieClip("cont", 1);
cont._x = mask._x;
cont._y = mask._y;
cont.setMask(mask);
function go() {
i = 1;
this.onEnterFrame = function() {
if (i<=ID_max) {
if (i<=9) {
img = prefix+"00"+i+".jpg";
}
if (i>9 && i<=99) {
img = prefix+"0"+i+".jpg";
}
if (i>99) {
img = prefix+i+".jpg";
}
trace(img);
cont.attachMovie("box", "box"+i, i);
// assegno un nome di comodo al clip
mc = eval(cont["box"+i]);
mc._x = (W_box+Space_box)*i-W_box;
mc._y = 0;
// carico l'immagine
mc.path = img;
mc.pic_box.loadMovie(img);
mc.onEnterFrame = function() {
if (this.pic_box.getBytesLoaded()>1024 && this.pic_box.getBytesLoaded() == this.pic_box.getBytesTotal()) {
// calcolo dimensioni originali
this.larg = this.pic_box._width;
this.alt = this.pic_box._height;
trace(this.larg);
// chiamo la funzione di re-dimensionamento
this.pic_box._xscale = Math.floor(_level0.W_box_pic*100/this.larg);
this.pic_box._yscale = Math.floor(_level0.H_box_pic*100/this.alt);
this.pic_box._alpha = 0;
this.pic_box.onEnterFrame = function() {
// enterFrame per aumentare gradualmente l'alpha dell'immagine caricata
if (this._alpha<100) {
this._alpha += 20;
} else {
this._alpha = 100;
delete this.onEnterFrame;
}
};
this.pic_box.setMask(this.msk);
tot++;
delete this.onEnterFrame;
}
};
// -----------------------
mc.onPress = function() {
_level0.attachMovie("big", "big", 1000);
_level0.big._x = this._x;
_level0.big._y = this._y;
_level0.big.box.loadMovie(this.path);
_level0.big.box._alpha = 0;
clickon._alpha = 0;
sfondo._alpha = 100;
_level0.big.onEnterFrame = function() {
if (this.box.getBytesLoaded()>1024 && this.box.getBytesLoaded() == this.box.getBytesTotal()) {
//Lo rimetto alle sue vere dimensioni
this.box._xscale = this.box._yscale=100;
//Dimensioni Originali
W = this.box._width;
H = this.box._height;
//
// ridimensionamento dell'immagine in base all'area disponibile
//
MaxW = 1024;
// larghezza massima disponibile
MaxH = 550;
// altezza massima disponibile
MaxP = MaxH*100/MaxW;
// % larghezza su altezza
//
theW = W;
// larghezza effettiva
theH = H;
// altezza effettiva
theP = theH*100/theW;
// rapporto W/H
//
if (W>MaxW) {
if (H>MaxH) {
if (theP<=MaxP) {
theW = MaxW;
theH = MaxW*theP/100;
} else {
theW = MaxH/theP*100;
theH = MaxH;
}
} else {
theW = MaxW;
theH = MaxW*theP/100;
}
} else {
if (H>MaxH) {
theW = MaxH/theP*100;
theH = MaxH;
} else {
// qui l'immagine sta già dentro l'area disponibile
// per cui le istruzioni seguenti sono "ridondanti"
// le ho lasciate "commentate" per una miglior lettura...
//theW = W; // larghezza effettiva
//theH = H; // altezza effettiva
}
}
// imposto Larghezza e Altezza con i valori calcolati
theW = Math.floor(theW);
theH = Math.floor(theH);
this.box._width = theW;
this.box._height = theH;
_level0.big._x = (MaxW-_level0.big._width)/2;
_level0.big._y = 100+(MaxH-_level0.big._height)/2;
this.box.onEnterFrame = function() {
if (this._alpha<99) {
this._alpha += 20;
} else {
this._alpha = 99;
delete this.onEnterFrame;
}
};
delete this.onEnterFrame;
}
// fine If
};
// fine enter Frame
};
//fine McOnPress
// -----------------------
i++;
} else {
delete this.onEnterFrame;
}
// fine IF
};
//fine enter
}
// fine function
p.onPress = function() {
cont.onEnterFrame = function() {
if (cont._x+cont._width>mask._x+mask._width) {
cont._x -= (W_box+Space_box);
}
};
};
p.onRelease = function() {
delete cont.onEnterFrame;
};
m.onPress = function() {
cont.onEnterFrame = function() {
if (cont._x<mask._x) {
cont._x += (W_box+Space_box);
}
};
};
m.onRelease = function() {
delete cont.onEnterFrame;
};
start.onPress = function() {
cont._x = mask._x;
};
end.onPress = function() {
cont._x = mask._x+mask._width-cont._width-5;
};
close.onPress = function() {
big.unloadMovie();
clickon._alpha = 100;
sfondo._alpha = 0;
};
![]()