1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
function init(){
//declaration de variables
nbrCont = 8;
nbrCouche = 3;
distanceCopie = 4;
main();
}
function main(){
for(j=1;j<=nbrCont;j++){
eval("_root.cont"+j).onRollOver = function() {
for(i=1;i<=nbrCouche;i++){
duplicateMovieClip(this,"copie"+j+i,i);
eval("copie"+j+i)._alpha=eval("copie"+j+i)._alpha / i;
eval("copie"+j+i).newPosY=eval("copie"+j+i)._y-(nbrCouche*i); //Get the y position
eval("copie"+j+i).newPosX=eval("copie"+j+i)._x-(nbrCouche*i); //Get the x position
eval("copie"+j+i).onEnterFrame=function(){
this._y = ease(this._y,this.newPosY,1,2); //Ease in on the y axis
this._x = ease(this._x,this.newPosX,1,2); //Ease in on the x axis
};
}
};
eval("_root.cont"+j).onRollOut = function () {
for(i=1;i<=nbrCouche;i++){
eval("copie"+j+i).newPosY=this._y; //Get the y position
eval("copie"+j+i).newPosX=this._x; //Get the x position
function(){
this._y = ease(this._y,this.newPosY,1,2); //Ease in on the y axis
this._x = ease(this._x,this.newPosX,1,2); //Ease in on the x axis
}
}
};
}
}
function ease(currX, destX, acc, dec) { // function to ease
var distanceX
var vx
distanceX = destX - currX;
vx = (vx + (distanceX) * 1/acc) / dec;
currX += vx;
return currX;
} |
Partager