Ci-joint une version améliorée avec une application en bonus...

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
 
unit UTrackbar;
 
interface
uses Flash8;
 
 
type
 
   TTrackcur=class(MovieClip)
    orientation:string;
    xmouse,ymouse,trackmin,trackmax:number;
    xcur,ycur:Integer;
    downcur:Boolean;
    Procedure circle(Cx,Cy,Radius:number);
    constructor Create(AOWNER:Movieclip;trmin,trmax:number);
    procedure onPress;
    procedure onEnterFrame;
    procedure onMouseUp;
   end;
 
   TTrackbar=class(MovieClip)
    w,h,position:number;
    state:string;
    cur: TTrackcur;
    procedure Roundrect(x,y,w,h,radius:number);
    procedure DrawTrackbar(Width,Height:number);
    constructor Create(AOWNER:Movieclip;FTaille,trmin,trmax,posi:number;Kind:string);
   end;
 
implementation
 
 
constructor TTrackcur.create(AOWNER:Movieclip;trmin,trmax:number);
 var matrix: Flash8.Matrix;
begin
  inherited Create(AOWNER,'cur',AOWNER.getNextHighestDepth);
  matrix := Flash8.Matrix.Create();
  matrix.createBox(1,1,0,10,14);
  linestyle(1,$87B6B7);
  beginGradientFill('radial',[$008080,clwhite],[100,100],[0,14],matrix);
  Circle(6,6,15);
  downcur:=false;
  xmouse:=0;
  ymouse:=0;
  trackmin:=trmin;
  trackmax:=trmax;
end;
 
constructor TTrackbar.Create(AOWNER:Movieclip;FTaille,trmin,trmax,posi:number;Kind:string);
begin
 inherited Create(AOWNER,'trackbar',AOWNER.getNextHighestDepth);
 w:=FTaille;
 state:=Kind;
 DrawTrackBar(w,12);
 cur:=TTrackcur.Create(self,trmin,trmax);
 cur.orientation:=Kind;
 position:=posi;
 if kind='horizontal' then
 begin
  cur._x:=(posi-trmin)*w/(trmax-trmin);
  cur._y:=0;
 end else
 if kind='vertical' then
 begin
  cur._y:=(trmax-posi)*w/(trmax-trmin);
  cur._x:=0;
 end;
end;
 
procedure TTrackbar.DrawTrackbar(Width, Height: number);
var matrix: Flash8.Matrix;
begin
 matrix := Flash8.Matrix.Create();
 if state='horizontal' then
 begin
  matrix.createGradientBox(width, height, Math.PI/2, 0, 0);
  beginGradientFill('linear',[$deedf6,$c4e5f6,$98d1ef,$66afd7],[100,100,100,100],[8,64,127,255],matrix);
  linestyle(2,$98d1ef);
  RoundRect(0,0,width,height,height/2);
 end else if state='vertical' then
 begin
  matrix.createGradientBox(height,width,0, 0, 0);
  beginGradientFill('linear',[$deedf6,$c4e5f6,$98d1ef,$66afd7],[100,100,100,100],[8,64,127,255],matrix);
  RoundRect(0,0,height,width,height/2);
  linestyle(2,$98d1ef);
 end;
end;
 
procedure  TTrackcur.onPress;
begin
 downcur:=true;
 xmouse:=_xmouse;
 ymouse:=_ymouse;
end;
 
procedure  TTrackcur.onEnterFrame;
var tr:TTrackbar;
begin
     tr:= TTrackbar(_parent);
 
     if downcur then
     if orientation='horizontal' then
     begin
      _x:= _x + _xmouse -xmouse;
      if _x<0 then _x:=0;
      if _x>tr.w then _x:=tr.w;
      tr.position:=_x*(trackmax-trackmin)/tr.w+trackmin;
     end
     else if orientation='vertical' then
     begin
      _y:= _y +_ymouse -ymouse;
      if _y<0 then _y:=0;
      if _y>tr.w then _y:=tr.w;
      tr.position:=trackmax-(_y*(trackmax-trackmin)/tr.w);
     end;
end;
 
 
 
procedure  TTrackcur.onMouseUp;
begin
 downcur:=false;
end;
 
procedure TTrackbar.Roundrect(x,y,w,h,radius:number);
var
 ra,b:number;
begin
  ra := x + w;
  b := y + h;
  moveTo(x+radius, y);
  lineTo(ra-radius, y);
  CurveTo(ra,y, ra, y+radius);
  lineTo(ra, y+h-radius);
  CurveTo(ra, b, ra-radius, b);
  lineTo(x+radius, b);
  CurveTo(x, b,x, b-radius);
  lineTo(x, y+radius);
  CurveTo(x, y, x+radius,y);
end;
 
Procedure TTrackcur.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;
 
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
 
program PNewton;
 
{$FRAME_WIDTH 560}
{$FRAME_HEIGHT 520}
{$FRAME_RATE 32}
{$BACKGROUND $F0F0F0}
 
uses
  Flash8,UTrackbar;
 
  type
    newton=class(movieclip)
     procedure secteur(x,y,tetai,tetaf,rayon:number);
     Procedure circle(Cx,Cy,Radius:number);
    end;
 
   Essai=class(movieClip)
    Track:TTrackbar;
    mc:Newton;
    Constructor Create;
    procedure onEnterFrame;
   end;
 
 
 
Constructor Essai.Create;
var teta,R:number;
begin
 inherited create(nil,'essai',0);
 teta:=360/7;
 R:=250;
 mc:=Newton.create(self,'disque de Newton',0);
 with mc do
 begin
  beginfill(clblack);
  circle(0,0,R+5);
  EndFill();
  beginFill($B73C2A);
  secteur(0,0,0,teta,R);
  beginFill($90266E);
  secteur(0,0,teta,2*teta,R);
  beginFill($2F98D1);
  secteur(0,0,2*teta,3*teta,R);
  beginFill($ACC5D6);
  secteur(0,0,3*teta,4*teta,R);
  beginFill($80B043);
  secteur(0,0,4*teta,5*teta,R);
  beginFill($D9D81D);
  secteur(0,0,5*teta,6*teta,R);
  beginFill($CC7E29);
  secteur(0,0,6*teta,360,R);
  EndFill();
  beginFill(clblack);
  circle(0,0,20);
  EndFill();
 
  beginfill($C0C0C0);
  circle(0,0,3);
  _x:=260;
  _y:=260;
 end;
  track:=TTrackbar.Create(self,400,0,180,3,'vertical');
  with track do
  begin
   _x:=530;
   _y:=60;
  end;
end;
 
procedure Newton.secteur(x,y,tetai,tetaf,rayon:number);
var  lineangle,contdist,Endx,Endy,contx,conty:number;
     i:integer;
begin
  tetai:=tetai*math.pi/180;
  tetaf  :=tetaf*math.pi/ 180;
  lineangle:=(tetaf-tetai)/8;
  contdist:=rayon/cos(lineangle/2);
  moveto(x+rayon*cos(tetai),y-rayon*sin(tetai));
  for i:= 1 to 8 do
  begin
   endx:=x+rayon*cos(tetai+i*lineangle);
   endy:=y-rayon*sin(tetai+i*lineangle);
   contx:=x+contdist*cos(tetai+i*lineangle-lineangle/2);
   conty:=y-contdist*sin(tetai+i*lineangle-lineangle/2);
   curveto( contx,conty,endx,endy);
  end;
    moveto(x,y);
    lineto(x+rayon*cos(tetai),y-rayon*sin(tetai));
    lineto(x+rayon*cos(tetaf),y-rayon*sin(tetaf));
end;
 
 
 
procedure essai.onEnterFrame;
begin
 mc._rotation:=mc._rotation+track.position;
end;
 
Procedure Newton.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;
 
begin
  Essai.create;
end.
c'est brut de décoffrage mais ça marche.
j'aurais pu modifier circle pour le déclarer une seule fois...entre autre.
Bon, le but était de faire aussi un trackbar vertical...