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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248
| <code>
//****************************************************************************
// ActionScript Extend Library
//CadrePhoto
//****************************************************************************
[Inspectable(name="Largeur Images", variable="largeur", type="Number", defaultValue=800)]
[Inspectable(name="Hauteur Images", variable="hauteur", type="Number", defaultValue=600)]
[Inspectable(name="Fichier XML", variable="xmlfilephoto", type="String",defaultValue="")]
[Inspectable(name="Alpha", variable="playalpha", type="Number", defaultValue=100)]
[Inspectable(name="Delai", variable="delai", type="Number", defaultValue=1000)]
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
dynamic class CadrePhoto extends MovieClip
{
/*private var __hauteur:Number ;
private var __largeur:Number ;
private var __delai:Number ;
private var __numberPhoto:Number;
private var __x:Number;
private var __y:Number;
private var __xmlFile:String;
private var XmlParserPhoto:XML;
private var node1:Object;
private var i:Number;
private var __left:Number=0;
private var __function:String;
private var __erreur:String;
private var __alpha;
private var __photo:Array;
private var containerPhoto:MovieClip
private var listPhoto:Object;
private var movieClipPhotol:MovieClipLoader;
private var __photoActuelle:Number;
private var __nomPhotoActuelle:String;
private var __timePhoto:Number;*/
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function CadrePhoto(largeur:Number,hauteur:Number,delai:Number,playalpha:Number)
{
_root.success= new Boolean();
__hauteur=hauteur;
__largeur=largeur;
__delai=largeur;
__alpha=playalpha;
__photoActuelle=0;
__photo=new Array(String);
}
public function XmlFile()
{
//séparer nom prénom du contact
var send_lv:LoadVars = new LoadVars();
var result_lv:LoadVars = new LoadVars();
send_lv.contact= _level0.contact;
result_lv.onLoad = function(success1:Boolean)
{
if (success1)
{
__xmlFile ="./upload/"+result_lv.user+"/.photo.xml";
trace("xml1"+__xmlFile);
success=true;
} else
{
__erreur="Pas de xml déterminé";
success=false;
}
}
send_lv.sendAndLoad("split.php",result_lv,"POST");
}
public function get etat():Boolean
{
return success;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public function ParseXML():Number
{
XmlParserPhoto=new XML();
XmlParserPhoto.ignoreWhite = true;
trace("xmlfile"+__xmlFile);
XmlParserPhoto.onLoad = function(Reussite2:Boolean)
{
trace("parser");
if(Reussite2)
{
node1 = XmlParserPhoto.firstChild;
for(i = 0; node1.childNodes[i] != undefined; i++)
{
if(!node1.childNodes[i].childNodes[0])
{ //Si il n'existe pas
__numberPhoto = -1;
trace("node pb");
return 0;
}
else
{ //Si il existe
__photo[i] =(node1.childNodes[i].childNodes[0].attributes.name);
trace("node"+node1.childNodes[i].childNodes[0].attributes.name);
trace(__photo[i]);
__numberPhoto = i;
return 1;
}
}
}
else
{
return "Erreur lors du chargement du fichier XML";
}
}
XmlParserPhoto.load(__xmlFile);
return 1;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public function NextPhoto():String
{
trace("nextphoto");
//incrémentation du curseur
__photoActuelle++;
//si on est pas à la fin
if (__photoActuelle <=__numberPhoto)
{
//attribution de la valeur du tableau correspondant a __photoActuelle
trace("nom="+__photo[__photoActuelle]);
__nomPhotoActuelle= __photo[__photoActuelle];
return __photoActuelle+"/"+__numberPhoto;
//appel de la fonction qui va charger l'image
}
else
{
//si on est à la fin, on rénitialise le curseur
__photoActuelle=-1;
}
}
public function PrevPhoto():String
{
//incrémentation du curseur
__photoActuelle--;
//si on est pas à la fin
if (__photoActuelle >=0)
{
return __photoActuelle+"/"+__numberPhoto;
//attribution de la valeur du tableau correspondant a _root.__photoActuelle
__nomPhotoActuelle= __photo[__photoActuelle];
}
else
{
//si on est à la fin, on rénitialise le curseur
__photoActuelle=__numberPhoto;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public function LoadPicture()
{
//on crée un clip vide dans lequel on va charger notre image
_root.containerPhoto= new MovieClip;
_root.containerPhoto= _root.createEmptyMovieClip("containerPhoto",this.getNextHighestDepth());
//on définit un écouteur qui écoutera ce que raconte le MovieClipLoader (pour savoir quand le chargement sera fini)
listPhoto= new Object();
//on définit le MovieClipLoader qui chargera l'image dans notre containerPhoto
movieClipPhotol= new MovieClipLoader();
//on dit à notre écouteur d'écouter ce que raconte le MovieClipLoader
movieClipPhotol.addListener(listPhoto);
//on remet l'échelle du containerPhoto à 100%
_root.containerPhoto._xscale = 100;
_root.containerPhoto._yscale = 100;
//fonction qui sera appelée quand l'écouteur entendra que le chargement est terminé
listPhoto.onLoadInit = function(target_movieClipPhoto:MovieClip)
{
trace("list");
//on va faire un petit fondu pour l'apparition de l'image, ça donne toujours bien
//on mets donc l'alpha à 0 pour commencer
target_movieClipPhoto._alpha = 0;
//on calcule le ratio hauteur cadre par rapport à la hauteur de l'image (qui sera utilisé pour redimensionner l'image si elle trop grande pour le cadre)
//var percent_w:Number = (cadre._width - marge_w) * 100 / target_movieClipPhoto._width;
var percent_w:Number = (__largeur*100)/400;
//var percent_h:Number = (cadre._height - marge_h) * 100 / target_movieClipPhoto._height;
var percent_h:Number = (__hauteur*100)/300;
//idem en largeur
//on doit encore centrer l'image dans le cadre (son coin supérieur gauche est en (0,0) pour le moment)
//on centre l'image en x
target_movieClipPhoto._x = __x;
//on centre l'image en y
target_movieClipPhoto._y = __y;
target_movieClipPhoto._xscale = percent_w;
target_movieClipPhoto._yscale = percent_w;
//on affiche l'image avec un fondu
target_movieClipPhoto.onEnterFrame = function()
{
//on augmente de 5 jusqu'à arriver à __alpha
this._alpha += 5;
//si on est à 100 (ou plus pour être sûr)
if(this._alpha > __alpha)
{
//on met à 100 (des fois qu'on aurait dépassé pour une raison x ou y)
this._alpha = __alpha;
//on supprimer le onEnterFrame pour arrêter de boucler dedans
delete this.onEnterFrame;
}
}
}
trace("nomphoto="+__nomPhotoActuelle);
trace( _root.containerPhoto);
//On dit au MovieClipLoader de lancer le chargement de l'image dans le clip containerPhoto
movieClipPhotol.loadClip(__nomPhotoActuelle, _root.containerPhoto);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
</code> |
Partager