Bonjour,
J'ai un petit problème pour appeler un fonction.
Je souhaite faire un redimensionnement d'image après un chargement mais ma fonction nécessite des paramètres car je compte la réutiliser plusieurs fois pour différentes image dans différent Loader et UILoader
photo et du type Loader.
var photo:Loader;
Et affphoto est un UILoader posé sur ma scène
Mon appel :
photo.contentLoaderInfo.addEventListener(Event.COMPLETE,resizephoto(photo,affphoto));
Ma fonction:
function resizephoto(evt:Event,imgload:Loader,cont:UILoader):void {
//redimensionnement de l'image
imgload.content.scaleX=imgload.scaleY=1;
var skaleH:Number=1;
var skaleL:Number=1;
if (imgload.content.height>cont.height && imgload.content.height>imgload.content.width) {
skaleH=affphoto.height/imgload.content.height;
}
else if (photo.content.width>cont.width && imgload.content.width>imgload.content.height) {
skaleL=cont.width/imgload.content.width;
}
imgload.content.scaleX=imgload.content.scaleY=Math.min(skaleL,skaleH);
//affichage de l'image
cont.addChild(imgload);
//remise a l'endroit de la photo
if(nbrot!=0){
if(nbrot == 1)
{
largeurx = imgload.content.height;
imgload.content.rotation += 90;
}
if(nbrot == 2)
{
hauteury = imgload.content.height;
largeurx = imgload.content.width;
imgload.content.rotation += 180;
}
if(nbrot == 3)
{
largeurx=0;
hauteury=photo.content.width;
imgload.content.rotation += 270;
}
imgload.content.x=largeurx;
imgload.content.y=hauteury;
}
}
Je suis sur que c'est tout bête mais j'arrive pas a trouver.
Merci d'avance pour votre aide