je t'avoue que je ne connais pas cette méthode...
je te mets le code peg' ça t'aideras à y voir plus clair peut être
import gs.easing.*;
import gs.TweenLite;
import flash.net.URLRequest;
var photoList:Array = new Array();
var currentPhoto:int = 0;
for (var i:uint =0;i<5;i++) {
// url de l'image ou du swf à charger
var image:URLRequest = new URLRequest("images/portraits"+i+".jpg");
// création du conteneur de l'image ou du swf
var conteneurImage:Loader = new Loader();
// Evénement progress
conteneurImage.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
// Progression du chargement
function onProgress(evt:ProgressEvent):void {
var p:Number=(evt.bytesLoaded*100)/evt.bytesTotal;
}
// Evénement complete
conteneurImage.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
function onComplete (evt:Event):void {
for (var i:int=0;i<photoList.length;i++){
// currentPhoto visible
if(i != 0)
{
// not visible and ready to fade In
photoList[i].alpha = 0.0;
photoList[i].visible = false;
}
// affichage du conteneur
photoList[i].alpha=0;
this.addChild(photoList[i]);
TweenLite.to (photoList[i], 1, {alpha:1});
photoList[i].x = (stage.stageWidth/2)-(photoList[i].width/2);
TweenLite.to (btn_right,1,{x:photoList[0].x+(photoList[0].width+50),alpha:1});
TweenLite.to (btn_left,1,{x:photoList[0].x-50,alpha:1});
}
}
// chargement de l'image ou du swf dans le conteneur
conteneurImage.load(image);
// push img obj in photoList Array
photoList.push(conteneurImage)
//conteneurImage.x = 0;
}
function right (e:MouseEvent):void {
if (currentPhoto==4) {
TweenLite.to (photoList[currentPhoto], 0.5, {alpha:0.0, onComplete:function():void
{photoList[4].visible = false;
currentPhoto = 0;
photoList[currentPhoto].visible = true;
TweenLite.to (photoList[currentPhoto],1, {alpha:1})
TweenLite.to (btn_right,1,{x:photoList[currentPhoto].x+(photoList[currentPhoto].width+50)});
TweenLite.to (btn_left,1,{x:photoList[currentPhoto].x-50});
}})
}
else{
TweenLite.to (photoList[currentPhoto],1, {alpha:0.0, onComplete:function():void
{
photoList[currentPhoto].visible = false;
photoList[++currentPhoto].visible = true;
photoList[currentPhoto].x = (stage.stageWidth/2)-(photoList[currentPhoto].width/2);
TweenLite.to (photoList[currentPhoto],1, {alpha:1.0});
TweenLite.to (btn_right,1,{x:photoList[currentPhoto].x+(photoList[currentPhoto].width+50)});
TweenLite.to (btn_left,1,{x:photoList[currentPhoto].x-50});
}})
}
}
function left (e:MouseEvent):void {
if (currentPhoto==0) {
TweenLite.to (photoList[currentPhoto], 0.5, {alpha:0.0, onComplete:function():void
{photoList[0].visible = false;
currentPhoto = 4;
photoList[currentPhoto].visible = true;
TweenLite.to (photoList[currentPhoto],1, {alpha:1})
TweenLite.to (btn_right,1,{x:photoList[currentPhoto].x+(photoList[currentPhoto].width+50)});
TweenLite.to (btn_left,1,{x:photoList[currentPhoto].x-50});
}})
}
else {
TweenLite.to (photoList[currentPhoto],0.5, {alpha:0.0, onComplete:function():void
{
photoList[currentPhoto].visible = false;
photoList[--currentPhoto].visible = true;
photoList[currentPhoto].x = (stage.stageWidth/2)-(photoList[currentPhoto].width/2);
TweenLite.to (photoList[currentPhoto],0.5, {alpha:1});
TweenLite.to (btn_right,1,{x:photoList[currentPhoto].x+(photoList[currentPhoto].width+50)});
TweenLite.to (btn_left,1,{x:photoList[currentPhoto].x-50});
}
})
}
}
btn_right.addEventListener (MouseEvent.CLICK, right)
btn_left.addEventListener (MouseEvent.CLICK, left)
|