Précédent   Forum du club des développeurs et IT Pro > Autres langages > Pascal > Flash Pascal
Flash Pascal Forum d'entraide sur la création de fichiers Flash en Object Pascal
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Actualité déjà publiée
 
Outils de la discussion
Publicité
'
Vieux 23/06/2012, 22h10   #1
Paul TOTH
Expert Confirmé Sénior
 
Avatar de Paul TOTH
 
Homme Paul TOTH
Freelance
Inscription : novembre 2002
Messages : 4 427
Détails du profil
Informations personnelles :
Nom : Homme Paul TOTH
Âge : 43
Localisation : Réunion

Informations professionnelles :
Activité : Freelance
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : novembre 2002
Messages : 4 427
Points : 10 824
Points : 10 824
Par défaut Défi FlashPascal #1

Je ne cherche pas à concurrencer les défi de développez, mais je me dis qu'il serait sympa d'animer un peu ce forum avec de petits défis de programmation FlashPascal.

ce premier défi consiste à coder l'effet suivant par vous même
light.jpg

il existe plusieurs techniques, dont une est exposée ici, j'en ai choisi une autre.

voici ma version FlashPascal compilée Light.swf

Et pour ceux qui ne trouverais pas comment coder ce genre de choses (ma solution tient en 140 lignes correctement indentées mais sans commentaire), vous pouvez également proposer votre propre effet graphique.

A vos claviers !

Sur ce je vous dit bonne nuit !
__________________
Developpez.com: Mes articles, forum FlashPascal
Entreprise: Execute SARL
Produits : UPnP, RemoteOffice, FlashPascal
Embarcadero : Ile de la Réunion, Dephi, C++Builder, RADPHP...TVA à 8,5%
Paul TOTH est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/06/2012, 11h34   #2
Archimède
Membre émérite
 
Avatar de Archimède
 
Homme anthony
Enseignant
Inscription : avril 2005
Messages : 1 028
Détails du profil
Informations personnelles :
Nom : Homme anthony
Localisation : France, Charente Maritime (Poitou Charente)

Informations professionnelles :
Activité : Enseignant
Secteur : Enseignement

Informations forums :
Inscription : avril 2005
Messages : 1 028
Points : 979
Points : 979
En regardant ton défi, j'ai découvert encore un bug sur le with...
Pour le défi, je ne suis pas sur la bonne piste, j'en suis conscient...
L'objet camera est à regarder de près !... ou bitmapdata avec FloodFill mais je ne pense pas, le remplissage serait plus complet...

ci-joint pour le bug : (désolé, j'utilise URealmovie et UColor, c'était pour regarder vite fait)

Code :
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
 
 program PLight;
 
{$FRAME_WIDTH 1000}
{$FRAME_HEIGHT 520}
{$FRAME_RATE 12}
{$BACKGROUND $000000}
 
uses
  Flash8,URealmovie,UColor;
 
  Type
   Light=class(movieclip)
    x,y:number;
    Procedure circle(Cx,Cy,Radius:number);
    procedure draw;
    constructor create(parent:movieclip;depth:number);
   End;
 
  espace=class(Realmovie)
   projo:Light;
   constructor Create;
   procedure onMouseMove;
  end;
 
Procedure Light.circle(Cx,Cy,Radius:number);
var a,b,R: number;
begin
  R:=Radius;
  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;
 
 
constructor Light.Create(parent:movieclip;depth:number);
begin
 inherited Create(parent,'light',depth);
end;
 
 
procedure Light.Draw;
var m:Matrix;
begin
 m:=matrix.create();
 m.createbox(1,1,0,x,y);
 begingradientfill('radial',[$FFFFFF,$000000],[100,100],[15,100],m);
 circle(x,y,150);
 endFill();
end;
 
Constructor espace.Create;
begin
 inherited Create(_root,'espace',1);
 setsize(1000,520,-10,-10,10,10);
 linestyle(3,clred);
 Rline(4,4,8,4);
 projo:=Light.create(_root,0);
 mouse.hide;
end;
 
//procedure espace.onMouseMove;  ici, ça ne marche pas
//begin
// with projo do
// begin
//  clear;
//  x:=_xmouse;
//  y:=_ymouse;
//  draw;
// end;
//end;
 
procedure espace.onMouseMove;
begin
 projo.clear;
 projo.x:=_xmouse;
 projo.y:=_ymouse;
 projo.draw;
end;
 
begin
 espace.create;
end.
Code :
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
 
unit URealMovie;
 
interface
 
uses
 math,flash8;
 
const
  Pi   = 3.14159265359;
type
 Tpoint=record
  x,y:number;
 end;
 
 TArrayofPoint = array of TPoint;
 RealMovie = class(MovieClip)
   graph_width,graph_height:integer;
   xmin, xmax, ymin ,ymax , xsize ,ysize , Gx, Gy ,xo ,yo: number;
   Procedure RMoveTo(x,y:number);
   Procedure RMoveTo2(pt:TPoint);
   Procedure RLineTo(x,y:number);
   Procedure RLineTo2(pt:TPoint);
   Procedure RLine(x1,y1,x2,y2:number);
   procedure RLine2(pt1,pt2:Tpoint);
   Procedure RPolyline(courbe:array of TPoint);
   Procedure Rrectangle(x1,y1,x2,y2:number);
   Procedure Rrectangle2(pt1,pt2:TPoint);
   procedure RRoundrect(x,y,w,h,radius:number);
   Procedure RCircle(Cx,Cy,Radius:number);
   Procedure RCurveTo(x1,y1,x2,y2:number);
   procedure RArrow(x1,y1,x2,y2:number;col,penw:integer); //flèche
   procedure RArrow2(Fx,Fy,norme,alpha:number;col,penw:integer);//en coords polaires /alpha en °
   procedure Rdisquegradue(xc,yc,R,L:number;n:integer);
   function  Rrotationarraypoint(xc,yc,theta:number;figure:array of Tpoint):TarrayofPoint;
   function  RPoint(x,y:number):TPoint;
   procedure RTextout(x,y,width,height,Depth:number;font:TextFormat;text:String);
   procedure Rdisquegradtextout(xc,yc,R:number;n:integer;font:TextFormat;text:array of String);
   procedure setSize(w, h: Integer; x1, y1, x2, y2: Number);
  end;
 
 function IntToStr2(i: Integer): string;
 function IntToStr3(i: Integer): string;
 function pt(x,y:number):TPoint;
 function FloattostrF(num:number;digit:integer):String;
 function sqr(n:number):number;
 
implementation
 
// Méthodes de dessin de Realmovie
 
 
function sqr(n:number):number;
begin
 result:=n*n;
end;
 
function IntToStr2(i: Integer): string;
begin
  Result := IntToStr(i);
  if i < 10 then
    Result := '0' + Result;
end;
 
function pt(x,y:number):TPoint;
begin
 result.x:=x;
 result.y:=y;
end;
 
 
function FloattostrF(num:number;digit:integer):String;
var int:integer;
    frac,frac1,frac2,newnum:number;
begin
   int:=trunc(num);
   frac:=num-int;
   frac1:=trunc(pow(10,digit)*frac)/pow(10,digit);
   frac2:= trunc(pow(10,digit+1)*frac)/pow(10,digit+1);
   if (frac2-frac1)*pow(10,digit+1)>=5 then newnum:=int+frac1+pow(10,-digit) else newnum:=int+frac1;
   result:=floattostr(newnum);
end;
 
function IntToStr3(i: Integer): string;
begin
  Result := IntToStr(i);
  if (i<100) and (i<>0) and (i>=10) then Result:='0'+Result else if (i<10) and (i<>0) then Result:='00'+Result else if i =0 then Result :='000';
end;
 
 
procedure RealMovie.RRoundrect(x,y,w,h,radius:number);
var
 r,b,xe,ye,we,he:number;
begin
  xe:=xo+x*Gx;
  ye:=yo-y*Gy;
  we:=w*Gx;
  he:=h*Gy;
  r := xe + we;
  b := ye + he;
  moveTo(xe+radius, ye);
  lineTo(r-radius, ye);
  CurveTo(r, ye, r, ye+radius);
  lineTo(r, ye+he-radius);
  CurveTo(r, b, r-radius, b);
  lineTo(xe+radius, b);
  CurveTo(xe, b, xe, b-radius);
  lineTo(xe, ye+radius);
  CurveTo(xe, ye, xe+radius, ye);
end;
 
Procedure RealMovie.RMoveTo(x,y:number);
begin
 Moveto(xo+x*Gx,yo-y*Gy);
end;
 
Procedure RealMovie.RMoveTo2(pt:TPoint);
begin
 Moveto(xo+pt.x*Gx,yo-pt.y*Gy);
end;
 
Procedure RealMovie.RLineTo(x,y:number);
begin
 Lineto(xo+x*Gx,yo-y*Gy);
end;
 
Procedure RealMovie.RLineTo2(pt:TPoint);
begin
 Lineto(xo+pt.x*Gx,yo-pt.y*Gy);
end;
 
Procedure RealMovie.RLine(x1,y1,x2,y2:number);
begin
 RMoveto(x1,y1);
 RLineto(x2,y2);
end;
 
procedure RealMovie.RLine2(pt1,pt2:Tpoint);
begin
  RLine(pt1.x,pt1.y,pt2.x,pt2.y);
end;
 
 
Procedure RealMovie.RPolyline(courbe:array of TPoint);
var i:integer;
begin
  RMoveto2(courbe[0]);
  for i:=1 to high(courbe) do Rlineto2(courbe[i]);
end;
 
Procedure RealMovie.Rrectangle(x1,y1,x2,y2:number);
begin
 RMoveto(x1,y1);
 RLineTo(x2,y1);
 RLineto(x2,y2);
 RLineto(x1,y2);
 RLineto(x1,y1);
end;
 
Procedure RealMovie.Rrectangle2(pt1,pt2:TPoint);
begin
 RMoveto2(pt1);
 RLineTo(pt2.x,pt1.y);
 RLineto2(pt2);
 RLineto(pt1.x,pt2.y);
 RLineto2(pt1);
end;
 
Procedure RealMovie.Rcircle(Cx,Cy,Radius:number); //si orthonormé
var a,b,R: number;
begin
  R:=radius*Gx;
  Cx:=xo+Cx*Gx;
  Cy:=yo-Cy*Gy;
  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:number;col,penw:integer);//flèche
var i:integer;
    Norme,cX,cY: number;
    ALength,AWidth:number;  //longueur et largeur de la pointe
    Arrow:array of TPoint;
begin
  ALength:=10;
  AWidth:=7;
  x1:=xo+x1*Gx;
  x2:=xo+x2*Gx;
  y1:=yo-y1*Gy;
  y2:=yo-y2*Gy;
  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]:=pt(x2,y2);
  Arrow[1]:=pt(x2-cX*ALength+cY*AWidth,y2-cY*ALength-cX*AWidth);
  Arrow[2]:=pt(x2-cX*ALength-cY*AWidth,y2-cY*ALength+cX*AWidth);
  Arrow[3]:=pt(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:number;col,penw:integer);//Flèche en coords polaires
var theta: number;
    L,L1: number;
    xf1,yf1 :number;
    xf2,yf2 :number;
    x,y : number;
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:number);
begin
 curveto(xo+x1*Gx,yo-y1*Gy,xo+x2*Gx,yo-y2*Gy);
end;
 
procedure RealMovie.Rdisquegradue(xc,yc,R,L:number;n:integer);
var phi:number;
    i:integer;
    pt1,pt2:Tpoint;
begin
 phi:=2*pi/n;
 for i:=0 to n do
 begin
  pt1:=pt(xc+(R-L)*cos(i*phi),yc+(R-L)*sin(i*phi));
  pt2:=pt(xc+R*cos(i*phi),yc+R*sin(i*phi));
  RLine2(pt1,pt2);
 end;
end;
 
 
function RealMovie.Rrotationarraypoint(xc,yc,theta:number;figure:array of Tpoint):TarrayofPoint;
var i:integer;
    Rayon,phi:array of number;
    O:TPoint;
    ptarray:array of Tpoint;
begin
 O:=pt(xo+Gx*xc,yo-Gy*yc);
 i := 4;
 for i:=low(figure) to high(figure) do
 begin
  ptarray[i]:=pt(xo+Gx*figure[i].x,yo-Gy*figure[i].y);
  if ptarray[i].x-O.x<>0 then phi[i]:=atan2(ptarray[i].y-O.y,ptarray[i].x-O.x) else phi[i]:=-pi/2;
  Rayon[i]:=round(sqrt(sqr(ptarray[i].x-O.x)+sqr(ptarray[i].y-O.y)));
  ptarray[i].x:=O.x+Rayon[i]*cos(theta+phi[i]);
  ptarray[i].y:=O.y+Rayon[i]*sin(theta+phi[i]);
  result[i]:=pt(ptarray[i].x,ptarray[i].y);
 end;
end;
 
procedure RealMovie.RTextout(x,y,width,height,Depth:number;font:TextFormat;text:String);
var Field:TextField;
begin
 Field:=TextField.Create(self,'',Depth,xo+Gx*(x),yo-Gy*(y),width,height);
 Field.setNewTextFormat(font);
 Field.text:=text;
end;
 
procedure RealMovie.Rdisquegradtextout(xc,yc,R:number;n:integer;font:TextFormat;text:array of String);
var i:integer;
    x,y,phi:number;
begin
 phi:=2*Pi/n;
 for i:=1 to n do
 begin
  x:=xc+R*cos(pi/2-i*phi);
  y:=yc+R*sin(pi/2-i*phi);
  RTextout(x,y,25,20,i,font,text[i]);
 end;
end;
 
Function  RealMovie.RPoint(x,y:number):TPoint;
begin
 result.x:=xo+x*Gx;
 result.y:=yo-y*Gy;
End;
 
procedure RealMovie.setSize(w, h: Integer; x1, y1, x2, y2: Number);
begin
  graph_width:=w;
  graph_height:=h;
  xmin := x1;
  xmax := x2;
  ymin := y1;
  ymax := y2;
  xsize:= xmax - xmin;
  ysize:= ymax - ymin;
  Gx   := graph_width / xsize;
  Gy   := graph_height/ ysize;
  xo   :=-xmin * Gx;
  yo   := ymax * Gy;
end;
//fin méthodes realmovie
 
 
end.
Code :
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
 
unit UColor;
 
interface
 
uses Flash8;
 
const
 clBlack=$000000;
 clWhite=$ffffff;
 clYellow=$ffff00;
 clfuchsia=$FF00FF;
 claqua=$00FFFF;
 clorange=$FFA500;
 clBlue=$0000ff;
 clGreen=$008000;
 clRed=$FF0000;
 cllime=$00FF00;
 clsilver=$C0C0C0;
 clGray=$808080;
 clGold=$FFD700;
 cldarkturquoise=$00CED1;
 claliceblue=$F0F8FF;
 clazure=$F0FFFF;
 clbrown=$A52A2A;
 clcadetblue=$5F9EA0;
 clcoral=$FF7F50;
 cllightskyblue=$87CEFA;
 clmediumspringgreen=$00FA9A;
 clmediumturquoise=$48D1CC;
 clmediumaquamarine=$66CDAA;
 clmediumblue=$0000CD;
 clmediumorchid=$BA55D3;
 clmediumpurple=$9370DB;
 clmediumseagreen=$3CB371;
 clmediumslateblue=$7B68EE;
 clnavajowhite=$FFDEAD;
 clnavy=$000080;
 clorchid=$DA70D6;
 clpowderblue=$B0E0E6;
 clpalegoldenrod=$EEE8AA;
 clpalegreen=$98FB98;
 clpaleturquoise=$AFEEEE;
 clspringgreen=$00FF7F;
 cltomato=$FF6347;
 clyellowgreen=$9ACD32;
 clwheat=$F5DEB3;
 clslategray=$708090;
 clturquoise=$40E0D0;
 clsalmon=$FA8072;
 clsandybrown=$F4A460;
 clseagreen=$2E8B57;
 
 
Function GetRvalue(coul:integer):integer;
Function GetGvalue(coul:integer):integer;
Function GetBvalue(coul:integer):integer;
Function RGB(R,V,B:integer):number;
 
implementation
 
 
 
Function GetBvalue(coul:integer):integer;
begin
 result :=coul mod 256;
end;
 
Function GetGvalue(coul:integer):integer;
begin
 result :=floor((Coul mod 65536)/256);
end;
 
Function GetRvalue(coul:integer):integer;
begin
 result :=Floor(Coul/65536);
end;
 
Function RGB(R,V,B:integer):number;
begin
 result:=65536*R+256*V+B;
end;
 
end.
__________________
Citation:
tout développeur plongé dans son code subit une poussée d'urticaire de bas en haut égale au poids du volume d'unités qu'il ajoute.
Archimède est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/06/2012, 12h16   #3
Archimède
Membre émérite
 
Avatar de Archimède
 
Homme anthony
Enseignant
Inscription : avril 2005
Messages : 1 028
Détails du profil
Informations personnelles :
Nom : Homme anthony
Localisation : France, Charente Maritime (Poitou Charente)

Informations professionnelles :
Activité : Enseignant
Secteur : Enseignement

Informations forums :
Inscription : avril 2005
Messages : 1 028
Points : 979
Points : 979
En fait, je ne devrais pas faire ça puisque _xmouse et _ymouse ne correspondent pas à espace mais dans le with à projo (projecteur)...

Ceci dit, j'ai tenté de faire :

Code :
1
2
3
4
5
6
7
8
9
10
11
 
procedure espace.onMouseMove;
begin
with projo do
begin
 clear;
 x:=_root._xmouse;
 y:=_root._ymouse;
 draw;
end;
end;
et là, ça devrait me règler le problème..et pourtant, ça ne marche toujours pas...
__________________
Citation:
tout développeur plongé dans son code subit une poussée d'urticaire de bas en haut égale au poids du volume d'unités qu'il ajoute.
Archimède est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/06/2012, 13h02   #4
Archimède
Membre émérite
 
Avatar de Archimède
 
Homme anthony
Enseignant
Inscription : avril 2005
Messages : 1 028
Détails du profil
Informations personnelles :
Nom : Homme anthony
Localisation : France, Charente Maritime (Poitou Charente)

Informations professionnelles :
Activité : Enseignant
Secteur : Enseignement

Informations forums :
Inscription : avril 2005
Messages : 1 028
Points : 979
Points : 979
pour le programme principal, j'ai encore fait l'erreur de tout redessiner...

Rectif :

Code :
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
 
program PLight;
 
{$FRAME_WIDTH 1000}
{$FRAME_HEIGHT 520}
{$BACKGROUND $000000}
 
uses
  Flash8,URealmovie,UColor;
 
  Type
   Light=class(movieclip)
    x,y:number;
    Procedure circle(Cx,Cy,Radius:number);
    procedure draw;
    constructor create(parent:movieclip;depth:number);
   End;
 
  espace=class(Realmovie)
   projo:Light;
   constructor Create;
   procedure onMouseMove;
  end;
 
Procedure Light.circle(Cx,Cy,Radius:number);
var a,b,R: number;
begin
  R:=Radius;
  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;
 
 
constructor Light.Create(parent:movieclip;depth:number);
begin
 inherited Create(parent,'light',depth);
end;
 
 
procedure Light.Draw;
var m:Matrix;
begin
 m:=matrix.create();
 m.createbox(1,1,0,0,0);
 begingradientfill('radial',[clWhite,clBlack],[100,100],[15,100],m);
 circle(0,0,150);
 endFill();
end;
 
Constructor espace.Create;
begin
 inherited Create(_root,'espace',1);
 setsize(1000,520,-10,-10,10,10);
 linestyle(3,clred);
 Rline(4,4,8,4);
 projo:=Light.create(_root,0);
 projo.draw;
 mouse.hide;
end;
 
procedure espace.onMouseMove;
begin
 projo._x:=_xmouse;
 projo._y:=_ymouse;
end;
 
//ou 
 
//procedure espace.onMouseMove;
//begin
// with projo do
// begin
// _x:=_root._xmouse;
// _y:=_root._ymouse;
// end;
//end;
 
 
begin
 espace.create;
end.
__________________
Citation:
tout développeur plongé dans son code subit une poussée d'urticaire de bas en haut égale au poids du volume d'unités qu'il ajoute.
Archimède est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/06/2012, 15h14   #5
Archimède
Membre émérite
 
Avatar de Archimède
 
Homme anthony
Enseignant
Inscription : avril 2005
Messages : 1 028
Détails du profil
Informations personnelles :
Nom : Homme anthony
Localisation : France, Charente Maritime (Poitou Charente)

Informations professionnelles :
Activité : Enseignant
Secteur : Enseignement

Informations forums :
Inscription : avril 2005
Messages : 1 028
Points : 979
Points : 979
non camera, rien à voir, c'est pour des captures video...
Le problème, je pense est que tu tapes un peu trop haut dans le niveau alors que l'on a pas assez de docs sur les différents outils de l'unité Flash8.
Sur les filtres par exemple...!
Je pense qu'actionscript2 permet de faire ça très simplement sans aller dans des considérations mathématiques trop poussées.
Le souci, c'est que l'on est obligé de se débrouiller avec des méthodes d'objets de l'unité Flash8 entièrement en anglais sans aucune explication...Roland l'avait déjà suggéré...

Difficile sans en être le concepteur de manipuler tes outils actionscript2 remodelés...
__________________
Citation:
tout développeur plongé dans son code subit une poussée d'urticaire de bas en haut égale au poids du volume d'unités qu'il ajoute.
Archimède est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/06/2012, 16h12   #6
Paul TOTH
Expert Confirmé Sénior
 
Avatar de Paul TOTH
 
Homme Paul TOTH
Freelance
Inscription : novembre 2002
Messages : 4 427
Détails du profil
Informations personnelles :
Nom : Homme Paul TOTH
Âge : 43
Localisation : Réunion

Informations professionnelles :
Activité : Freelance
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : novembre 2002
Messages : 4 427
Points : 10 824
Points : 10 824
Bonjour,

bon début

alors le bug est connu, les champs d'un objet ne sont pas initialisés...et ça fait foirer le with, tu peux corriger ce point en leur donnant la valeur 0 dans le constructor.

Code :
1
2
3
4
5
6
7
 
constructor Light.Create(parent:movieclip;depth:number);
begin
 inherited Create(parent,'light',depth);
 x := 0;
 y := 0;
end;
on a exactement le même problème en ActionScript en fait
Code c :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 
class Test {
	var x: Number;
	var y: Number;
/*
	function Test() {
		x = 0;
		y = 0;
	}
*/
}
c  = new Test();
with (c) {
	x = 1;
	y = 2;
}
trace(c.x + ',' + c.y); // undefined, undefined sans le constructor

par contre la bonne écriture est la suivante

Code :
1
2
3
4
5
6
7
8
9
10
11
 
procedure espace.onMouseMove; 
begin
 with projo do
 begin
  clear;
  x:=self._xmouse;
  y:=self._ymouse;
  draw;
 end;
end;
à l'intérieur du with, self pointe toujours sur espace et tu peux donc accéder à ses propriétés par ce biais.
__________________
Developpez.com: Mes articles, forum FlashPascal
Entreprise: Execute SARL
Produits : UPnP, RemoteOffice, FlashPascal
Embarcadero : Ile de la Réunion, Dephi, C++Builder, RADPHP...TVA à 8,5%
Paul TOTH est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 24/06/2012, 16h48   #7
Archimède
Membre émérite
 
Avatar de Archimède
 
Homme anthony
Enseignant
Inscription : avril 2005
Messages : 1 028
Détails du profil
Informations personnelles :
Nom : Homme anthony
Localisation : France, Charente Maritime (Poitou Charente)

Informations professionnelles :
Activité : Enseignant
Secteur : Enseignement

Informations forums :
Inscription : avril 2005
Messages : 1 028
Points : 979
Points : 979
Merci, en fait au départ pour corriger, j'avais mis self mais ça ne me réglait pas le problème, donc j'ai pensé à _root qui ne m'a toujours pas réglé le souci.
Pour cause... x := 0; y := 0; dans le create.... et j'ai laissé _root...
Pourtant, il me semblait avoir testé aussi:
projo.x:=0;
projo.y:=0; dans le create d'espace...(j'avais pensé à les initialiser)

En fait, il fallait les mettre dans le Create de Light...

Ok merci.. De toute façon la méthode de tout redessiner est mauvaise (encore ce réflexe Delphi) mais le clear m'a fait réagir ...
__________________
Citation:
tout développeur plongé dans son code subit une poussée d'urticaire de bas en haut égale au poids du volume d'unités qu'il ajoute.
Archimède est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/06/2012, 17h13   #8
Archimède
Membre émérite
 
Avatar de Archimède
 
Homme anthony
Enseignant
Inscription : avril 2005
Messages : 1 028
Détails du profil
Informations personnelles :
Nom : Homme anthony
Localisation : France, Charente Maritime (Poitou Charente)

Informations professionnelles :
Activité : Enseignant
Secteur : Enseignement

Informations forums :
Inscription : avril 2005
Messages : 1 028
Points : 979
Points : 979
on peut bien faire des chose comme ça mais je ne sais pas si je suis sur la bonne voie...

Code :
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
 
program PLight;
 
{$FRAME_WIDTH 1000}
{$FRAME_HEIGHT 520}
{$FRAME_RATE 12}
{$BACKGROUND $000000}
 
uses
  Flash8,URealmovie,UColor;
 
  Type
   Light=class(movieclip)
    x,y:number;
    Procedure circle(Cx,Cy,Radius:number);
    procedure draw;
    constructor create(parent:movieclip;depth:number);
   End;
 
  espace=class(Realmovie)
   projo:Light;
   constructor Create;
   procedure onMouseMove;
  end;
 
Procedure Light.circle(Cx,Cy,Radius:number);
var a,b,R: number;
begin
  R:=Radius;
  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;
 
 
constructor Light.Create(parent:movieclip;depth:number);
begin
 inherited Create(parent,'light',depth);
end;
 
 
procedure Light.Draw;
var m:Matrix;
begin
 m:=matrix.create();
 m.createbox(1,1,0,0,0);
 begingradientfill('radial',[clWhite,clBlack],[100,100],[15,100],m);
 circle(0,0,150);
 endFill();
end;
 
Constructor espace.Create;
begin
 inherited Create(_root,'espace',1);
 setsize(1000,520,-10,-10,10,10);
 beginFill(clblack);
 Rrectangle(-2,6,8,10);
 Rrectangle(-2,4,8,-10);
 linestyle(3,clred);
 Rline(-2,4,8,4);
 Rline(-2,6,8,6);
 projo:=Light.create(_root,0);
 projo.draw;
 mouse.hide;
end;
 
procedure espace.onMouseMove;
begin
  with projo do
 begin
 _x:=self._xmouse;
 _y:=self._ymouse;
 end;
end;
 
 
begin
 espace.create;
end.
__________________
Citation:
tout développeur plongé dans son code subit une poussée d'urticaire de bas en haut égale au poids du volume d'unités qu'il ajoute.
Archimède est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/06/2012, 18h02   #9
Paul TOTH
Expert Confirmé Sénior
 
Avatar de Paul TOTH
 
Homme Paul TOTH
Freelance
Inscription : novembre 2002
Messages : 4 427
Détails du profil
Informations personnelles :
Nom : Homme Paul TOTH
Âge : 43
Localisation : Réunion

Informations professionnelles :
Activité : Freelance
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : novembre 2002
Messages : 4 427
Points : 10 824
Points : 10 824
y'a de l'idée

mais encore faut-il que le spot soit visible de l'autre côté de la ligne
__________________
Developpez.com: Mes articles, forum FlashPascal
Entreprise: Execute SARL
Produits : UPnP, RemoteOffice, FlashPascal
Embarcadero : Ile de la Réunion, Dephi, C++Builder, RADPHP...TVA à 8,5%
Paul TOTH est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/06/2012, 18h14   #10
Archimède
Membre émérite
 
Avatar de Archimède
 
Homme anthony
Enseignant
Inscription : avril 2005
Messages : 1 028
Détails du profil
Informations personnelles :
Nom : Homme anthony
Localisation : France, Charente Maritime (Poitou Charente)

Informations professionnelles :
Activité : Enseignant
Secteur : Enseignement

Informations forums :
Inscription : avril 2005
Messages : 1 028
Points : 979
Points : 979
Oui, je sais j'ai bien compris le truc. il faut utiliser des curveto d'obturation qui couvrent au fur et à mesure le spot en fonction du move...
__________________
Citation:
tout développeur plongé dans son code subit une poussée d'urticaire de bas en haut égale au poids du volume d'unités qu'il ajoute.
Archimède est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 25/06/2012, 02h19   #11
Roland Chastain
Membre Expert
 
Homme Roland Chastain
Inscription : décembre 2011
Messages : 689
Détails du profil
Informations personnelles :
Nom : Homme Roland Chastain
Âge : 39
Localisation : Mali

Informations professionnelles :
Secteur : Enseignement

Informations forums :
Inscription : décembre 2011
Messages : 689
Points : 1 005
Points : 1 005
Je participe.
Fichiers attachés
Type de fichier : swf dfp_01.swf (243 octets, 7 affichages)
__________________
L'Art est long et le Temps est court.
Roland Chastain est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 25/06/2012, 11h21   #12
Archimède
Membre émérite
 
Avatar de Archimède
 
Homme anthony
Enseignant
Inscription : avril 2005
Messages : 1 028
Détails du profil
Informations personnelles :
Nom : Homme anthony
Localisation : France, Charente Maritime (Poitou Charente)

Informations professionnelles :
Activité : Enseignant
Secteur : Enseignement

Informations forums :
Inscription : avril 2005
Messages : 1 028
Points : 979
Points : 979
A mon avis pour faire avancer le chmibilic, il faut déjà se faire une routine de tracé de secteur comme ça pour pouvoir obturer exactement le spot lorsque l'on atteint le début des lignes qui constituent le tube...

Code :
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
 
program PSecteur;
 
{$FRAME_WIDTH 500}
{$FRAME_HEIGHT 500}
{$FRAME_RATE  32}
{$BACKGROUND $FFFFFF}
 
uses
  Flash8,UColor;
 
type
 espace=class(movieclip)
  theta,R:number;
  constructor Create;
  procedure onEnterFrame;
  procedure secteur(x,y,anglebegin,angleend,rayon:number);
 end;
 
 
 constructor espace.create;
 begin
  inherited Create(nil,'',0);
  theta:=0;
  R:=200;
 end;
 
 
 procedure espace.onEnterFrame;
 begin
  clear;
  if theta <180 then theta:=theta+5;
  beginfill(clblack);
  secteur(250,250,0,theta,R);
 end;
 
 
procedure espace.secteur(x,y,anglebegin,angleend,rayon:number);
var  lineangle,controldist,Endx,Endy,controlx,controly:number;
     i:integer;
begin
  Anglebegin:=Anglebegin*math.pi/180;
  Angleend  := Angleend*math.pi/ 180;
  lineangle:=( Angleend- Anglebegin)/8;
  controldist:=rayon/cos(lineangle/2);
  moveto(x+rayon*cos(anglebegin),y-rayon*sin(anglebegin));
  for i:= 1 to 8 do
  begin
   endx:=x+rayon*cos(anglebegin+i*lineangle);
   endy:=y-rayon*sin(anglebegin+i*lineangle);
   controlx:=x+controldist*cos(anglebegin+i*lineangle-lineangle/2);
   controly:=y-controldist*sin(anglebegin+i*lineangle-lineangle/2);
   curveto( controlx,controly,endx,endy);
  end;
    moveto(x,y);
    lineto(x+Rayon,y);
    lineto(x+rayon*cos(angleend),y-rayon*sin(angleend));
end;
 
 
begin
 espace.create;
end.
Je n'ai pas trop le temps de travailler dessus mais si ça peut en aider certains...

__________________
Citation:
tout développeur plongé dans son code subit une poussée d'urticaire de bas en haut égale au poids du volume d'unités qu'il ajoute.
Archimède est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 25/06/2012, 12h40   #13
Roland Chastain
Membre Expert
 
Homme Roland Chastain
Inscription : décembre 2011
Messages : 689
Détails du profil
Informations personnelles :
Nom : Homme Roland Chastain
Âge : 39
Localisation : Mali

Informations professionnelles :
Secteur : Enseignement

Informations forums :
Inscription : décembre 2011
Messages : 689
Points : 1 005
Points : 1 005
Pas facile le sujet, mais intéressant.

Je recommande l'usage de lunettes de soleil, ou alors d'utiliser une "ampoule" teintée : c'est ce que je vais faire pour ma part.
Fichiers attachés
Type de fichier : swf dfp_05.swf (446 octets, 5 affichages)
__________________
L'Art est long et le Temps est court.
Roland Chastain est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 25/06/2012, 13h54   #14
Paul TOTH
Expert Confirmé Sénior
 
Avatar de Paul TOTH
 
Homme Paul TOTH
Freelance
Inscription : novembre 2002
Messages : 4 427
Détails du profil
Informations personnelles :
Nom : Homme Paul TOTH
Âge : 43
Localisation : Réunion

Informations professionnelles :
Activité : Freelance
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : novembre 2002
Messages : 4 427
Points : 10 824
Points : 10 824
Citation:
Envoyé par Roland Chastain Voir le message
Pas facile le sujet, mais intéressant.

Je recommande l'usage de lunettes de soleil, ou alors d'utiliser une "ampoule" teintée : c'est ce que je vais faire pour ma part.
ou là ! tu prends une direction compliquée

Flash propose des tas de choses très sympathique qui font que cette effet est plutôt simple à réaliser en fait Archimède n'est pas très loin, on peut exploiter le fait que le fond est noir pour utiliser des caches noirs sur les zones qu'on ne veux pas illuminer.

Ne pas oublier qu'avec Flash, les MovieClip se superposent comme des calques. En plaçant les lignes rouge sur un MovieClip en avant plan elles seront toujours visibles. Si on place le spot en arrière plan il ne reste plus qu'à masquer en noir les zones d'ombre dans un MovieClip glissé entre les deux pour obtenir l'effet désiré
__________________
Developpez.com: Mes articles, forum FlashPascal
Entreprise: Execute SARL
Produits : UPnP, RemoteOffice, FlashPascal
Embarcadero : Ile de la Réunion, Dephi, C++Builder, RADPHP...TVA à 8,5%
Paul TOTH est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Actualité déjà publiée
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 08h25.


 
 
 
 
Partenaires

Hébergement Web