Bonjour,


J'ai commencé à faire une galerie photo en AS3. Quand je clique sur une image de la galerie elle s'affiche en grand. Mon problème est que lorsque la photo est zoomée elle ne se met pas au premier plan du coup on voit les autres photos.
Et je ne sais pas comment masquer les autres images quand une est zoomé.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
	public class GaleriePhoto  extends Sprite
	{
		private var gallerie:Rect;
		private var _pile:LoaderMax = new LoaderMax();
		private var _tablo:Array = [];
		private var xml:XML;
 
		// Indice de la vignette en cours de chargement
		private var imageActu:int = 0;
		private var caseName:Case;
 
		// Référence le conteneur pour les vignettes. Point de référence au centre de la scène
        private var _ctrC:Sprite;
 
		private var c:Case;
		var img:Sprite;
		private var pX:int;
		private var pY:int;
		private var ekar:int;
		private var sp:Sprite;
		public var _sprite:Sprite;
 
 
		public function GaleriePhoto(_xml:XML) 
		{
 
			xml = _xml;
			trace("galeriePhoto");
			trace(_xml);
			//gallerie = new Rect(-600, -300, int(G.$wST), int(G.$hST), 0xff0000);
			gallerie = new Rect(0, 0, int(G.$wST), int(G.$hST), 0xff0000);
			addChild(gallerie);
 
			for (var i:int = 0; i < _xml.*.length(); i++ )
			{
				trace("fichier photo :", _xml.photo.fichier[i]);
				_pile.append(new ImageLoader(_xml.photo.fichier[i], { name:'image'+i } ));
			}
 
			_pile.addEventListener(LoaderEvent.COMPLETE, pileComplet);
			_pile.load();
 
			G.$wFull = G.$wST - 40;
            G.$hFull = G.$hST - 40;
 
            // Création du conteneur
            _ctrC = new Sprite();
            addChild(_ctrC);
		}
 
		private function pileComplet(e:LoaderEvent):void 
		{
			trace("Pile complete");
			//buildGrille();
			buildGalerie();
		}
 
		private function buildGalerie():void
		{
			img	= _pile.getContent('image0');
			/*trace("image width *0.5 : " + img.width * .5, "image width : " + img.width);
			trace("image height *0.5 : " + (G.$hST - img.height) * .5, "image height : " + (G.$hST - img.height));*/
			pX = img.width * .5;
			pY = (G.$hST - img.height) * .5;
			ekar = 10;
 
 
			for (var i:int = 0 ; i < xml.*.length() ; i++)
			{
				trace("PILE", i)
				sp = new Sprite();
				sp.x = pX;
				sp.y = pY;
				sp.mouseChildren = false;
				addChild(sp);
 
				imageActu = i;
				img	= _pile.getContent('image' + i);
				_tablo.push(img);
				img.x = img.width * -.5;
				img.y = img.height * -.5;
				sp.addChild(img);
				pX += img.width + ekar;
 
				sp.addEventListener(MouseEvent.CLICK, zoom_image);
			}
		}
 
		private function zoom_image(e:MouseEvent):void 
		{
			var ratio:Number = Math.min(stage.stageWidth / e.currentTarget.width, stage.stageHeight / e.currentTarget.height);
			e.currentTarget.scaleX = e.currentTarget.scaleY = ratio;
			e.currentTarget.removeEventListener(MouseEvent.CLICK, zoom_image);
			e.currentTarget.addEventListener(MouseEvent.CLICK, dezoom_image);
			e.currentTarget.x = G.$wST * .5;
			e.currentTarget.y = G.$hST * .5;
			//addChild(e.currentTarget.name)
		}
 
		private function dezoom_image(e:MouseEvent):void 
		{
			e.currentTarget.scaleX = e.currentTarget.scaleY = 1;
			buildGalerie();
			e.currentTarget.removeEventListener(MouseEvent.CLICK, dezoom_image);
			e.currentTarget.addEventListener(MouseEvent.CLICK, zoom_image);
		}