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 50 51 52 53 54 55 56 57 58 59 60
|
<div style="margin-left:40px">var hScene:Number = Stage.height;
var wScene:Number = Stage.width;
var numOfItems:Number;
var radiusX:Number=300;
var radiusY:Number=110;
var centerX:Number=wScene/2;
var centerY:Number=hScene/2;
var nSpeed:Number=0.05;
var perspective:Number=100;
<div style="margin-left:40px">//chargement du xml
function load_xml(path:String,type:String){
var xml:XML = new XML();
xml.ignoreWhite = true;
xml.onLoad=function(){
var nodes = this.firstChild.childNodes;
numOfItems = nodes.length;
//appel fonction de création du caroussel quand tout est chargé.
genereCarousel(nodes);
}
xml.load("xml/"+path);
}
<div style="margin-left:40px">function genereCarousel(nodes){
level = this.getNextHighestDepth();
this.createEmptyMovieClip("carrousel"+iCarousel,iCarousel);
//creation d'un MovieClip vide pour accueillir le caroussel
clipHote = this["carrousel"+iCarousel];
for (var i=0;i<numOfItems ;i++){
//creation des Movieclip du caroussel (t)
var t=clipHote.attachMovie("item","item"+i,i+1);
t.angle = i* ((Math.PI*2)/numOfItems);
t._y=Math.sin(t.angle)*radiusY +centerY;
var s:Number = (t._y - perspective)/(centerY + radiusY - perspective)
t._xscale=t._yscale=s*50;
t._x=Math.cos(t.angle)*150+centerX;
t.icon.inner.loadMovie(nodes[i].attributes.image);
t.icon.smoothing=true;
//reflet
t.ref.inner.loadMovie(nodes[i].attributes.image);
t.swapDepths(Math.round(t._xscale) + 100 +i);
//mouvement
t.onEnterFrame = mover;
}
}
<div style="margin-left:40px">function mover(){
this.swapDepths(Math.round(this._xscale) + 100);
this._x=Math.cos(this.angle)* radiusX + centerX;
this._y=Math.sin(this.angle)* radiusY + centerY;
var s:Number = (this._y - perspective)/(centerY + radiusY- perspective);
this._xscale=this._yscale=s*100;
this.angle += nSpeed;
}
<div style="margin-left:40px">this.onMouseMove = function(){
//mise a jour de la variable de vitesse utilisée dans la fonction mover
nSpeed=(this._xmouse-centerX)/15000;
} </div></div></div></div></div> |
Partager