En ajoutant un bouton à mon unité VCL, lorsque j'implante une instance de TLabel et que je modifie la couleur de la police, je n'ai pas de problème alors que la modification de sa taille ne fonctionne pas.
Avec le bouton, j'ai fait exactement la même chose et là, je peux faire une modif de taille de police sans problème...
J'ai un comportement que je ne m'explique pas...

ci-joint :

rappel Ufont :
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
 
unit UFont;
 
interface
 
uses Flash8;
 
type
// TFontStyle =(fsBold,fsItalic,fsUnderline);  le type énuméré ne fonctionne pas.
// TStyle = set of TFontStyle;
 
 TFont=class
   private
    //FStyle:TStyle;
    procedure SetName(value:string);
    procedure SetSize(value:number);
    procedure Setcolor(value:number);
    //procedure SetStyle(value:TStyle);
    procedure SetBold(value:boolean);
    procedure SetItalic(value:boolean);
    procedure SetUnderline(value:boolean);
    procedure SetBullet(value:boolean);
    procedure Setalign(value:String);
   public
    FTextformat:TextFormat;
    constructor Create;
    property name:string read FTextFormat write SetName;
    property size:number read  FTextFormat write SetSize;
    //property style:Tstyle read  FStyle write SetStyle;
    property Bold:Boolean read  FTextFormat write SetBold;
    property Italic:Boolean read  FTextFormat write SetItalic;
    property Underline:Boolean read FTextFormat write SetUnderline;
    property Color:number read  FTextFormat write Setcolor;
    property Align:String read  FTextFormat write SetAlign;
    property Bullet:boolean read  FTextFormat write SetBullet;  //point equivalent à un tiret
 end;
 
implementation
 
Constructor TFont.Create;
begin
 FTextFormat:=TextFormat.Create('MS Sans Serif',8,0,false,false,false);
end;
 
procedure TFont.SetName(value:string);
begin
 FTextFormat.font:=value;
end;
 
procedure TFont.Setsize(value:number);
begin
  FTextFormat.size:=value;
end;
 
{procedure TFont.SetStyle(value:TStyle);
begin
 if [fsBold]*value=[fsBold] then FTextFormat.bold:=true;
 if [fsItalic]*value=[fsItalic] then FTextFormat.italic:=true;
 if [fsUnderline]*value=[fsUnderline] then FTextFormat.underline:=true;
end;}
 
procedure TFont.SetBold(value:boolean);
begin
 FTextFormat.bold:=value;
end;
 
procedure TFont.SetItalic(value:boolean);
begin
 FTextFormat.italic:=value;
end;
 
procedure TFont.SetUnderline(value:boolean);
begin
 FTextFormat.underline:=value;
end;
 
procedure TFont.Setcolor(value:number);
begin
   FTextFormat.color:=value;
end;
 
procedure TFont.Setalign(value:String);
begin
 FTextFormat.align:=value;
end;
 
procedure TFont.SetBullet(value:boolean);
begin
 FTextFormat.Bullet:=value;
end;
 
end.
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
 
unit UFlashVCL;
 
interface
 
uses Flash8,UFont;
 
const
  distance=1;
  angleInDegrees=45;
  coul1=$808080;
  highlightAlpha=0.8;
  coul2=$646464;
  shadowAlpha=0.9;
  blurX=5;
  blurY=5;
  strength=5;
  quality=3;
  typ='inner';
 
type
 TLabel=Class
  Private
   FBorder,FwordWrap,Fautosize,FBackground,FBackgroundcolor,Fmultiline,first:Boolean;
   FLeft,FTop,FWidth,FHeight,FBordercolor,Frotation:number;
   FCaption:string;
   FTextfield:TextField;
   procedure SetLeft(value:number);
   procedure SetTop(value:number);
   procedure SetWidth(value:number);
   procedure SetHeight(value:number);
   procedure SetBorder(value:boolean);
   procedure SetborderColor(value: Number);
   procedure SetwordWrap(value:boolean);
   procedure SetAutosize(value:boolean);
   procedure SetBackground(value:Boolean);
   procedure SetBackgroundColor(value:number);
   procedure Setmultiline(value: Boolean);
   procedure Setrotation(value: Number);
   procedure SetCaption(value:string);
  Public
   Font:Tfont;
   constructor Create(parent:movieclip);
   property Left:number read FLeft write SetLeft;
   property Top:number read FTop write SetTop;
   property width:number read FWidth write SetWidth;
   property height:number read FHeight write SetHeight;
   property Border:Boolean read FBorder write SetBorder;
   property BorderColor:number read FBordercolor write SetBordercolor;
   property wordWrap:boolean read FwordWrap write SetwordWrap;
   property autosize:boolean read Fautosize write Setautosize;
   property Background:boolean read FBackground write SetBackground;
   property Backgroundcolor:number read FBackgroundcolor write SetBackgroundcolor;
   property multiline:boolean read Fmultiline write Setmultiline;
   property rotation:number read Frotation write Setrotation;
   property caption:string read FCaption write setCaption;
end;
 
{*********
**Edit****
**********
 
 TEdit=class(TLabel)
  private
   FText:String;
   procedure SetText(value:string);
   procedure onKeyDown;
  public
   constructor Create(parent:movieclip);
   procedure onChange;virtual;
   property text:string read Ftext write settext;
 end;}
 
 
 
{*********
**Button**
**********}
 
 
 TButton=class(movieclip)
 
 private
  click,First:Boolean;
  FLeft,FTop,FWidth,FHeight:number;
  skin1,skin2:movieclip;
  w,h:number;
  title: TextField;
  bevel1,bevel2:BevelFilter;
  myfilterArray:TArray;
  procedure skin;
  procedure SetCaption(value:string);
  procedure SetLeft(value:number);
  procedure SetTop(value:number);
  procedure SetWidth(value:number);
  procedure SetHeight(value:number);
  procedure onPress;override;
  procedure onMouseUp;override;
 public
  Font:Tfont;
  procedure onClick;virtual;
  constructor create(parent:movieclip);
  property Caption:string read title write SetCaption;
  property Left:number read FLeft write SetLeft;
  property Top:number read FTop write SetTop;
  property width:number read FWidth write SetWidth;
  property height:number read FHeight write SetHeight;
 end;
 
 
implementation
 
Constructor TLabel.Create(parent:movieclip);
begin
 FTextfield:=TextField.Create(Parent,'',parent.getNextHighestDepth(),0,0,100,100);
 Font:=TFont.Create;
 with Font do
 begin
  name:='arial';
  size:=14;
 end;
 first:=true;
end;
 
procedure TLabel.Setleft(value:number);
begin
   FTextfield._x:=value;
end;
 
procedure TLabel.SetTop(value:number);
begin
   FTextfield._y:=value;
end;
 
procedure TLabel.SetWidth(value:number);
begin
   FTextfield._width:=value;
end;
 
procedure TLabel.SetHeight(value:number);
begin
   FTextfield._height:=value;
end;
 
procedure TLabel.SetBorder(value:boolean);
begin
   FTextfield.border:=value;
end;
 
procedure TLabel.SetBordercolor(value:number);
begin
   FTextfield.bordercolor:=value;
end;
 
procedure TLabel.SetwordWrap(value:Boolean);
begin
 FTextfield.wordWrap:=value;
end;
 
procedure TLabel.Setautosize(value:boolean);
begin
 if value then FTextfield.autosize:='center';
end;
 
procedure TLabel.SetBackground(value:Boolean);
begin
 FTextfield.background:=value;
end;
 
procedure TLabel.SetBackgroundcolor(value:number);
begin
 FTextfield.backgroundcolor:=value;
end;
 
procedure TLabel.Setmultiline(value:Boolean);
begin
 FTextfield.multiline:=value;
end;
 
procedure TLabel.Setrotation(value:number);
begin
 FTextfield._rotation:=value;
end;
 
 
procedure TLabel.SetCaption(value:string);
begin
 if first then
 begin
  FTextfield.setNewTextFormat(Font.FTextFormat);
  first:=false;
 end;
 FTextfield.text:=value;
end;
 
{*********
**Edit****
**********
 
Constructor TEdit.Create(parent:movieclip);
begin
 inherited Create(parent);
 FTextfield.type:='input';
 Key.Addlistener(self);
end;
 
procedure TEdit.SetText(value:string);
begin
 if first then
 begin
  FTextfield.setNewTextFormat(Font.FTextFormat);
  first:=false;
 end;
 FTextfield.text:=value;
end;
 
procedure TEdit.onKeyDown;
begin
 onChange;
end;
 
Procedure TEdit.onChange;
begin
end; }
 
 
{*********
**Button**
**********}
 
constructor TButton.Create(parent:movieclip);
begin
 inherited Create(parent,'button',movieclip(parent).getNextHighestDepth());
 w:=90;
 h:=30;
 left:=10;
 top:=10;
 myfilterArray:=TArray.Create();
 
 Font:=TFont.Create;
 with Font do
 begin
  name:='arial';
  size:=14;
  align:='center';
 end;
 
 skin1:=movieclip.create(self,'',1);
 skin2:=movieclip.create(self,'',2);
 
 with skin1 do
 begin
  bevel1:=BevelFilter.create(distance,angleInDegrees,coul1,highlightAlpha,coul2,shadowAlpha,blurX,blurY,strength,quality,typ);
  myfilterArray.Push(bevel1);
  filters := myfilterArray;
  BeginFill($F0F0F0);
  lineto(w,0);
  lineto(w,h);
  lineto(0,h);
 end;
 
 with skin2 do
 begin
  bevel2:=BevelFilter.create(distance,angleInDegrees,coul2,highlightAlpha,coul1,shadowAlpha,blurX,blurY,strength,quality,typ);
  myfilterArray.Push(bevel2);
  filters := myfilterArray;
  BeginFill($F0F0F0);
  lineto(w,0);
  lineto(w,h);
  lineto(0,h);
 end;
 
 First:=true;
 click:=false;
 skin;
 
 Title:=TextField.Create(self,'',getNextHighestDepth(),0,0,w,h);    //TLabel  ça bugue
 with Font do
 begin
  name:='arial';
  size:=20;
 end;
end;
 
procedure TButton.skin;
begin
 if not click then
 begin
  skin1._visible:=true;
  skin2._visible:=false;
 end else
 begin
  skin1._visible:=false;
  skin2._visible:=true;
 end;
end;
 
procedure TButton.SetCaption(Value: string);
begin
 with title do
 begin
  if first then
  begin
   setNewTextFormat(Font.FTextFormat);
   first:=false;
  end;
  text:=value;
 end;
end;
 
 
procedure TButton.onClick;
begin
end;
 
procedure TButton.onPress;
begin
 click:=true;
 skin;
 onClick;
end;
 
procedure TButton.onMouseUp;
begin
 click:=false;
 skin;
end;
 
procedure TButton.Setleft(value:number);
begin
 _x:=value;
end;
 
procedure TButton.SetTop(value:number);
begin
 _y:=value;
end;
 
procedure TButton.SetWidth(value:number);
begin
   _xscale:=100*value/w;
   _yscale:=_xscale;
end;
 
procedure TButton.SetHeight(value:number);
begin
  _yscale:=100*value/h;
end;
 
end.
l'essai :

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
 
program Project1;
 
{$FRAME_WIDTH 550}
{$FRAME_HEIGHT 400}
{$FRAME_RATE 12}
{$BACKGROUND $FFFFFF}
 
 
 
uses
  Flash8,UFlashVCL;
 
Type
 
 TButton1=class(TButton)
  procedure onClick;override;
 end;
 
 TButton2=class(TButton)
  procedure onClick;override;
 end;
 
 
var
 Button1: TButton1;
 Button2: TButton2;
 Label:TLabel;
 
procedure TButton1.onClick;
begin
 label.caption:='Button1';
end;
 
procedure TButton2.onClick;
begin
 label.caption:='Button2';
end;
 
begin
 
 Label:=TLabel.Create(_root);
 with Label do
 begin
  font.color:=clred;
  font.size:=20;   //c'était ici qu'en je modifiais...
  caption:="J'attends la modification";
  left:=15;
  top:=150;
  width:=500;
 end;
 
 Button1:=TButton1.create(_root);
 with Button1 do
 begin
  caption:='Button1';
  left:=15;
  top:=10;
  width:=120;
 end;
 
 Button2:=TButton2.create(_root);
 with Button2 do
 begin
  caption:='Button2';
  left:=15;
  top:=65;
  width:=120;
 end;
 
 
end.
En fait, je viens de comprendre... J'ai déclaré font:TFont dans mes deux classes TLabel et TButton. le même nom engendre des conflits...

Il doit y avoir un problème" d'encapsulation "si je peux m'exprimer ainsi.

si j'utilise font en même temps dans label et button, ça bugue avec la propriété size...et pas avec color (curieux...)