Sur un autre début d'application, je suis confronté à un conflit sur l'événement onpress entre deux movieclips parents.
J'ai donc utilisé l'événement onMousedown pour l'un et onpress pour le bouton...
Le soucis est de faire apparaître le curseur main avec l'événement onMousedown...

ci-joint un début de code :

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
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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
 
program Graph;
 
uses
  Flash8,Math,Key;
 
{$BACKGROUND $00fffff}
{$FRAME_WIDTH  768}
{$FRAME_HEIGHT 768}
{$FRAME_RATE 30}
 
const
 
  frame_width=768;
  frame_height=768;
  xmin = -10;
  xmax = +10; //ua
  ymin = - 10;
  ymax = + 10;//ua     
  xsize= xmax - xmin;
  ysize= ymax - ymin;
  Gx   = frame_width / xsize;
  Gy   = frame_height/ ysize;
  xo   =-xmin * Gx;
  yo   = ymax * Gy;
  Pi   = 3.141592654;
  GMs=6.67*pow(10,-11)*1.989*pow(10,30); //cst gravitationnelle*masse du soleil
  UA=150*pow(10,9); //unité astromomique en mètre 
  dt=1/150;  //1tour en 5 s
  Rmercure=0.387;//rayon traj mercure en UA
  Rvenus=0.723;
  Rterre=1;
  Rmars=1.52;
  Rjupiter=5.20;
  Rsaturne=9.51;
type
 
  TRpoint = external class(flash.geom.Point)
    constructor Create(x, y: double);
    property x: double;
    property y: double;
  end;
 
  TButton=class(MovieClip)
   Captionbut: TextField;
   constructor Create(AOWNER:Movieclip);
   procedure DoClick;
   procedure DrawButton(BackColor, TopColor, BottomColor, Width, Height: Integer);
   procedure GetFont2;
  end;
 
  RealMovie = class(MovieClip)
   tabmax:integer;
   Arrow: Array of TRPoint;
   courbe:Array of TRPoint;
   Procedure RMoveTo(x,y:double);
   Procedure RLineTo(x,y:double);
   Procedure RLine(x1,y1,x2,y2:double);
   Procedure RPolyline;// pas de possibilité de mettre un array of TRpoint en paramètre
   Procedure Rrectangle(x1,y1,x2,y2:double);
   Procedure RCircle(Cx,Cy,Radius:double);
   Procedure RCurveTo(x1,y1,x2,y2:double);
   procedure RArrow(x1,y1,x2,y2:double;col,penw:integer); //flèche
   procedure RArrow2(Fx,Fy,norme,alpha:double;col,penw:integer);//en coords polaires /alpha en °
   procedure zoom(k:Double);
   procedure Depx(dx:Double);
   procedure Depy(dy:Double);
  end;
 
  TGraphe = class(RealMovie)
    graph:TButton;
    caption:TextField;
    button:Tbutton;
    constructor Create;
    procedure GetPoint;
    procedure onEnterFrame;
    procedure Getspeed;
    procedure Getfont;
    procedure onMouseDown;
    procedure onMouseUp;
  end;
 
 var  radius:double; 
      speed,omega,Ra,xs,ys,theta:array[1..6] of double;
      t:Double;
      Font,Font2   : TextFormat;
      annee: Double;
      Bascule:boolean;
      Gkx,Gky:Double;
      ox,oy:Double;
      press:Boolean;
      mousex,mousey:Integer;
 
// Méthodes de dessin de Realmovie
Procedure RealMovie.RMoveTo(x,y:double);
begin
 Moveto(ox+x*Gkx,oy-y*Gky);
end;
 
Procedure RealMovie.RLineTo(x,y:double);
begin
 Lineto(ox+x*Gkx,oy-y*Gky);
end;
 
Procedure RealMovie.RLine(x1,y1,x2,y2:double);
begin
 RMoveto(x1,y1);
 RLineto(x2,y2);
end;
 
Procedure RealMovie.RPolyline;
var i:integer;
begin
  RMoveto(courbe[0].x,courbe[0].y);
  for i:=1 to tabmax-1 do Rlineto(courbe[i].x,courbe[i].y);
end;
 
Procedure RealMovie.Rrectangle(x1,y1,x2,y2:double);
begin
 RMoveto(x1,y1);
 RLineTo(x2,y1);
 RLineto(x2,y2);
 RLineto(x1,y2);
 RLineto(x1,y1);
end;
 
Procedure RealMovie.Rcircle(Cx,Cy,Radius:double); //si orthonormé
var a,b: Double;
      R: Double;
begin
  R:=radius*Gkx;
  Cx:=ox+Cx*Gkx;
  Cy:=oy-Cy*Gky;
  a:= R * 0.414213562;
  b:= R * 0.707106781;
  moveTo(Cx+R,Cy);
  CurveTo(Cx+ R, Cy+-a, Cx+b,Cy -b);
  CurveTo(Cx+ a,Cy-R,Cx,Cy -r);
  CurveTo(Cx-a,Cy -R,Cx-b,Cy -b);
  CurveTo(Cx-R, Cy-a,Cx-R,Cy);
  CurveTo(Cx-R,Cy+a,Cx-b,Cy+b);
  CurveTo(Cx-a,Cy +R,Cx,Cy+r);
  CurveTo(Cx+a,Cy +R,Cx+b,Cy+b);
  CurveTo(Cx+R,Cy+a,Cx+R,Cy);
end;
 
Procedure RealMovie.RArrow(x1,y1,x2,y2:double;col,penw:integer);//flèche
var i:integer;
    Norme,cX,cY: double;
    ALength,AWidth:double;  //longueur et largeur de la pointe
begin
  ALength:=10;
  AWidth:=7;
  x1:=ox+x1*Gkx;
  x2:=ox+x2*Gkx;
  y1:=oy-y1*Gky;
  y2:=oy-y2*Gky;                                                                                           
  Norme:=SQRT((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
  if Norme=0 then Exit;
  cX:=(x2-x1)/Norme;
  cY:=(y2-y1)/Norme;
  Arrow[0]:=TRPoint.create(x2,y2);
  Arrow[1]:=TRPoint.create(x2-cX*ALength+cY*AWidth,y2-cY*ALength-cX*AWidth);
  Arrow[2]:=TRPoint.create(x2-cX*ALength-cY*AWidth,y2-cY*ALength+cX*AWidth);
  Arrow[3]:=TRPoint.create(x2,y2);
 
  Linestyle(penw,col);
  BeginFill(col);
  Moveto(x1,y1);
  Lineto(x2,y2);
  Moveto(arrow[0].x,arrow[0].y);
  for i:=1 to 3 do lineto(arrow[i].x,arrow[i].y);
  Endfill();
end;
 
procedure RealMovie.RArrow2(Fx,Fy,norme,alpha:double;col,penw:integer);//Flèche en coords polaires
var 
    theta: Double;
    L,L1: Double;
    xf1,yf1 :Double;
    xf2,yf2 :Double;
    x,y : Double;
 
begin
 alpha:=pi*alpha/180;
 
 x:=norme*cos(alpha);
 y:=norme*sin(alpha);
 if x<>0.0 then theta:=atan2(y,x) else theta:=0;
 L:=sqrt((x*x)+(y*y))/10;
 L1:=L/2;
 
 xf1:=-L*cos(theta)-L1*sin(theta);
 xf2:=-L*cos(theta)+L1*sin(theta);
 yf1:=-L*sin(theta)+L1*cos(theta);
 yf2:=-L*sin(theta)-L1*cos(theta);
 
 linestyle(penw,col);
 RLine(Fx,Fy,Fx+x,Fy+y);
 RLine(x+Fx,y+Fy,x+Fx+xf1,y+Fy+yf1);
 RLine(x+Fx,y+Fy,x+Fx+xf2,y+Fy+yf2);
end;
 
procedure RealMovie.RCurveto(x1,y1,x2,y2:double);
begin
 curveto(ox+x1*Gkx,oy-y1*Gky,ox+x2*Gkx,oy-y2*Gky);
end;
 
procedure RealMovie.zoom(k:Double);
begin
 Gkx:=k*Gkx;
 GkY:=k*Gky; 
end;
 
procedure RealMovie.Depx(dx:Double);
begin
 ox:=ox+dx;
end;
 
procedure RealMovie.Depy(dy:Double);
begin
 oy:=oy+dy;
end;
 
//fin méthodes realmovie 
 
constructor TGraphe.Create;
var i:integer;
begin
  inherited Create(nil, 'graphe', 0);
  _x:=0;
  _y:=0;
  t:=0;
  Gkx:=Gx;
  Gky:=Gy;
  ox:=xo;
  oy:=yo;
  annee:=0;
  bascule:=true;
  GetFont;
  Caption := TextField.Create(Self, '',1,0,8,217,35);
  Caption.text:='NOMBRE D''ANNEES :';
  Caption.SetTextFormat(Font);
 
  button:=TButton.Create(self);
  button._x:=0;
  button._y:=733;
  getspeed;
  press:=false;
  useHandCursor:=false;
end;
 
procedure TGraphe.GetPoint;
var i:integer;
begin
 if bascule then t:=t+dt;
 for i:=1 to 6 do
 begin
  theta[i]:=omega[i]*t;
  xs[i]:=Ra[i]*cos(theta[i]);
  ys[i]:=Ra[i]*sin(theta[i]);
 end;
end;
 
procedure TGraphe.onEnterFrame;
var i:integer;
begin
 clear;
 Getpoint;
 beginfill($ffff00);
 RCircle(0,0,0.2);
 endFill();
 for i:=1 to 6 do 
 begin
  linestyle(1,$0000ff);
  RCircle(0,0,Ra[i]);
  beginfill($c0c0c0);
  RCircle(xs[i],ys[i],0.1);
  endFill();
 end;
 Rline(xs[6]-0.15,ys[6]-0.12,xs[6]+0.15,ys[6]+0.12);
 annee:=theta[3]/(2*pi);
 caption.text:='NOMBRE D''ANNEES :  '+ Floattostr(annee);
 Caption.SetTextFormat(Font);
 //zoom
 if isKeyDown(kbUP) then zoom(1.05);
 if isKeyDown(kbDOWN) then zoom(0.95);
 //déplacement scène
 if press then
 begin
  Depx(_xmouse-mousex);
  Depy(_ymouse-mousey);
  mousex:=_xmouse;
  mousey:=_ymouse;
 end;
end;
 
Procedure TGraphe.Getspeed;
var i:integer;
begin
 Ra[1]:=Rmercure;
 Ra[2]:=Rvenus;
 Ra[3]:=Rterre;
 Ra[4]:=Rmars;
 Ra[5]:=Rjupiter;
 Ra[6]:=Rsaturne;
 for i:=1 to 6 do speed[i]:=sqrt(GMs/(Ra[i]*UA));//VITESSE EN m/s 
 for i:=1 to 6 do omega[i]:=speed[i]*365.25*24*3600/(Ra[i]*UA); // vitesse angulaire en rad/année
end;
 
Procedure TGraphe.GetFont;
begin
 Font := TextFormat.Create('Tahoma', 16);
 Font.Align := 'left';
 Font.Bold := True;
 Font.Color := $000000;
end;
 
procedure TGraphe.onMouseDown;
begin
  useHandCursor:=true;
  press:=true;
  mousex:=_xmouse;
  mousey:=_ymouse;
end;
 
Constructor TButton.Create(AOWNER:Movieclip);
 begin
  inherited Create(AOWNER,'button',2);
  GetFont2;
  Captionbut := TextField.Create(self, '',0,0,8,100,35);
  Captionbut.text:='Stop';
  Captionbut.SetTextFormat(Font2);
  DrawButton($F0F0F0,$808080,008080,100, 35);
  Bascule:=true;
  onpress:=DoClick;
 end;
 
 Procedure TButton.DrawButton(BackColor, TopColor, BottomColor, Width, Height: Integer);
 begin
  beginFill(BackColor);
  lineStyle(5, TopColor);
  moveTo(0, Height);
  lineTo(0, 0);
  lineTo(Width, 0);
  lineStyle(5, BottomColor);
  lineTo(Width, Height);
  lineTo(0, Height);
  endFill;
 end; 
 
 Procedure TButton.doClick;
 begin
  Bascule:=not Bascule;
  if not Bascule then
  begin
   Captionbut.text:='Anime';
  end
  else
  begin
   Captionbut.text:='Stop';
  end;
  Captionbut.SetTextFormat(Font2);
 end;
 
Procedure TButton.GetFont2;
begin
 Font2 := TextFormat.Create('Tahoma', 12);
 Font2.Align := 'center';
 Font2.Bold := True;
 Font2.Color := $000000;
end;
 
procedure TGraphe.onMouseUp;
begin
 Press:=false;
end;
 
 
begin
  TGraphe.Create;
end.
a+