Bonjour,

j'ai des difficultés à comprendre l'accès au clip en as3, j'ai deux jolies livre, as3 programmation séquentielle et orienté objet et le meilleur de as3.
Quand je lis j'ai l'impression de bien tout comprendre mais passons à la pratique et la c'est autre chose...

le but, fait un effet dock

pour ca j'ai fais un clip modele dans ma biblio
dans liaison -> class -->clip.Panneau

sur ma scene principale j'ai mis dans classe du document
main.Main

mon fichier Panneau.as
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
package clip
{
 
	import flash.display.MovieClip;
	import flash.text.TextField;
 
 
	public class Panneau extends MovieClip
	{
 
 
 
 
		public function Panneau(nom:String,titre:String,posX:Number,posY:Number,reflet:Boolean)
		{
			this.name = nom;
			this.x = posX;
			this.y = 300;
			pan_titre.text = titre;
			if(reflet) addReflet();
 
			hidePanneau();			
		}
 
		private function hidePanneau():void
		{
			this.alpha =0 ;
		}
 
		private function addReflet()
		{
 
		}//fin fonction
 
 
	}//fin class
 
}//fin package
et mon fichier main.as
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
package main
{
 
	import config.*;
	import flash.display.*;
	import flash.text.TextField;
 
 
	public class Main extends Sprite
	{
 
		private var chargeur:	ConfigLoader;
		private var site:		Site;
 
 
 
		public function Main()
		{
 
			chargeur = new ConfigLoader("config.xml", completedConfigLoad);	
 
 
 
		}//fin fonction
 
		private function completedConfigLoad():void
		{
			site= new Site();
			addChild(site);
			site.ini();
			return;
 
		}
 
 
 
 
	}//fin classe
 
 
}// fin package
ma classe site:
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
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
package config
{
 
	import flash.display.*;
	import clip.*;
	import flash.text.TextField;
	import fl.transitions.easing.*;
	import fl.transitions.*;
	import flash.utils.Timer;
	import flash.events.TimerEvent;
	import flash.events.*;
 
 
 
	public class Site extends Sprite
	{
 
		public var panneau1:			Panneau;
		public var panneau2:			Panneau;
		public var panneau3:			Panneau;
		public var panneau4:			Panneau;
		public var panneau5:			Panneau;
		public var panneau6:			PanneauPub;
		public var panneau7:			PanneauPub;
		public var sp_contenu:			Sprite;
		public var sp_haut:				Sprite;
		private var anime_accueil:		Tween;
		private var decalage_ini_pann:	Number = 17;
		private var decalage_pann:		Number = 6;
		private var decalage_pann_pub:		Number = 6;
		private var width_pann:			Number = 135;
		private var width_pann_pub:		Number = 147;
		private var timer:				Timer;
		private var xmouse:				Number = mouseX ;
		private var ymouse:				Number = mouseY;
		private var hitTest:			Boolean;
		private var scale			: Number = Number.NEGATIVE_INFINITY;
		private var span:Number = 250;			
		private var icon_min:Number = 135;
		private var icon_size:Number = 135;
		private var icon_max:Number = 160;
		private var trend			: Number = 0;
		private var posClipX:Number;
		private var ratio:Number = Math.PI / 2 / span;
		private var amplitude			: Number= 10;
		private var posXclipInitial		:Array;
		private static const  centreXStage:int = 1040/2;
 
		public function Site()
		{
			madeSprite();
		}//fin fonction
 
		private function madeSprite():void
		{
			sp_haut = new Sprite();
			sp_contenu = new Sprite();
			sp_haut.x = 0;
			sp_haut.y= 0;
			sp_contenu.x = 0;
			sp_contenu.y = 100;
			addChild(sp_haut);
			addChild(sp_contenu);			
		}//fin fonction
 
		public function ini():void
		{
 
			panneau1 = new Panneau("panneau1","antonin",decalage_ini_pann + width_pann / 2,-233, true);
			sp_contenu.addChild(panneau1);
			panneau2 = new Panneau("panneau2","antonin2",(decalage_ini_pann + width_pann/2 ) + decalage_pann + width_pann ,-233, true);
			sp_contenu.addChild(panneau2);
			panneau3 = new Panneau("panneau3","antonin3",(decalage_ini_pann + width_pann/2 ) + (decalage_pann + width_pann) *2,-233, true);
			sp_contenu.addChild(panneau3);
			panneau4 = new Panneau("panneau4","antonin4",(decalage_ini_pann + width_pann/2 ) + (decalage_pann + width_pann) *3 ,-233, true);
			sp_contenu.addChild(panneau4);
			panneau5 = new Panneau("panneau5","antonin5",(decalage_ini_pann + width_pann/2 ) + (decalage_pann + width_pann) *4 ,-233, true);
			sp_contenu.addChild(panneau5);
			panneau6 = new PanneauPub("panneau6","antonin5",(decalage_ini_pann + width_pann/2 ) + (decalage_pann + width_pann) *5 + decalage_pann_pub,-233), true;
			sp_contenu.addChild(panneau6);
			panneau7 = new PanneauPub("panneau7","antonin5",(decalage_ini_pann + width_pann/2 ) + (decalage_pann + width_pann) *5 + 2* decalage_pann_pub + width_pann_pub ,-104), false;
			sp_contenu.addChild(panneau7);
			posXclipInitial = new Array((panneau1.x - centreXStage), (panneau1.x - centreXStage), (panneau2.x - centreXStage), (panneau3.x - centreXStage), (panneau4.x - centreXStage), (panneau5.x - centreXStage), (panneau6.x - centreXStage), (panneau7.x - centreXStage), false);
			showPanneauIntro();
 
 
 
		}//fin fonction
 
		public function showPanneauIntro():void
		{
 
			timer = new Timer(100,7);
			timer.addEventListener(TimerEvent.TIMER, doAnimeAccueil);
			timer.addEventListener(TimerEvent.TIMER_COMPLETE, endAnimeAccueil);
			timer.start();
		}//fin fonction
 
		private function doAnimeAccueil(evt:TimerEvent):void
		{
			var numClip:Number=evt.target.currentCount;
			anime_accueil = new Tween(this["panneau"+numClip],"y",Regular.easeIn,(this["panneau"+numClip].height /2 )+60,(this["panneau"+numClip].height /2 ),0.5,true);
			anime_accueil = new Tween(this["panneau"+numClip],"alpha",Regular.easeIn,0,1,0.5,true);
			anime_accueil = new Tween(this["panneau"+numClip].pan_titre,"alpha",Regular.easeIn,0,1,0.5,true);
		}//fin fonction
 
		private function endAnimeAccueil(evt:TimerEvent):void
		{
			timer.removeEventListener(TimerEvent.TIMER, doAnimeAccueil);
			timer.removeEventListener(TimerEvent.TIMER_COMPLETE, endAnimeAccueil);
			iniDockPan();
		}//fin fonction
 
		private function iniDockPan():void
		{
 
			sp_contenu.addEventListener(Event.ENTER_FRAME, moveDockPan);
 
		}//fin fonction
 
		private function moveDockPan(evt:Event):Boolean
		{
			var i:Number;			
			var x:Number;
			var dx:Number;
			var dim:Number;
			var largeur_dock:Number = this.parent.width;
 
 
			// Mouse did not move and Dock is not between states. Skip rest of the block.
			if((this.xmouse == this.mouseX) && (this.ymouse == this.mouseY) && ((this.scale <= 0.01) || (this.scale >= 0.99))) { return false; }
 
			// Mouse moved or Dock is between states. Update Dock.
			this.xmouse = this.mouseX;
			this.ymouse = this.mouseY;
 
			// Ensure that inflation does not change direction.
			this.trend = (this.trend == 0 ) ? (checkBoundary() ? 0.25 : -0.25) : (this.trend);
			this.scale += this.trend;
			if( (this.scale < 0.02) || (this.scale > 0.98) ) { this.trend = 0; }
 
			// Actual scale is in the range of 0..1
			this.scale = Math.min(1, Math.max(0, this.scale));
 
 
 
			// Hard stuff. Calculating position and scale of individual icons.
			for(i = 1; i < 8; i++) {
				dx = posXclipInitial[i] -  ( this.xmouse - largeur_dock/2)  ;
				dx = Math.min(Math.max(dx, -this.span), this.span);
				dim = this.icon_min + (this.icon_max - this.icon_min) * Math.cos(dx * this.ratio) * (Math.abs(dx) > this.span ? 0 : 1) * this.scale ;
				this["panneau"+i].x = posXclipInitial[i] + this.scale * this.amplitude * Math.sin(dx * this.ratio) + centreXStage;
				this["panneau"+i].scaleX = this["panneau"+i].scaleY =  (1 * dim / this.icon_size);	
				if (i>1)swapChildrenAt(this["panneau"+(i-1)],this["panneau"+(i)]);
 
			}
			var target:DisplayObject = this["panneau"+i]; 
			trace ( sp_contenu.getChildIndex(target));
			trace("------------");
 
			return true;
 
		}//fin fonction
 
		private function checkBoundary():Boolean
		{			
			if ((this.ymouse > 100 && this.ymouse < 500 && this.xmouse>6 && this.xmouse<1010) || (this.ymouse < -117 && this.ymouse > -335 && this.xmouse>216 && this.xmouse<517) )
			{
 
				return true;
			}else{
				return false;
			}
		}//fin fonction
 
 
	}//fin class
 
}//fin package
j'espere que le code comme ca brut vous embêteras pas trop...
tout fonctionne bien , mais par exemple dans la fonction moveDockPan, je veux connaitre le level de chaque occurence ( pour eviter quand on roll sur le dock qu'il y est le pb de recouvrement de clip devant -derriere)
si je fais
sp_contenu.getChildIndex(this["panneau"+i]) j'ai une erreur

je comprend pas comment manipuler mes clips

j'ai l'affreux sentiments mes clips sont pas là ou je crois , pour moi this["panneau"+i] est dans sp_contenu non?

merci de votre aide
antonin

ps:si y'a du code pas clair dites le moi je tenterais d'expliquer ce que j'ai fais

merci encore de votre patience