Ci-joint le short cut sur bouton que j'avais fait :

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
 
program Button;
 
uses
 Flash8;
 
{$FRAME_WIDTH   200}
{$FRAME_HEIGHT  70}
{$BACKGROUND $A6CAF0}
 
 
Type  
 TButton = class(MovieClip)
  Bascule:Boolean;
  Caption: TextField;
  format1,format2: TextFormat;
  constructor Create;
  procedure DoKeyDown;
  procedure DoClick;
  procedure DrawButton(BackColor, TopColor, BottomColor, Width, Height: Integer);
 end;
 
 
 Constructor TButton.Create;
 begin
  inherited Create(nil,'button',1);
  _x:=10;
  _y:=10;
  Format1 := TextFormat.Create('Arial', 14,$000000,true,false,false,'','','center');
  Format2:=TextFormat.Create();
  Format2.Underline := True;
  Caption := TextField.Create(Self, '', 0, 0,8,100,35);
  Caption.setNewTextFormat(Format1);
  Caption.text:='Stop';
  Caption.setTextFormat(0,1,Format2);
  DrawButton($F0F0F0,$808080,008080,100, 35);
  Key.addListener(self);
  Bascule:=False;
  onpress:=DoClick;
  onKeyDown:=DoKeyDown;
 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 Bascule then
  begin
   Caption.setNewTextFormat(Format1);
   Caption.text:='Play';
   Caption.setTextFormat(0,1,Format2);
   // commande à mettre ici
  end
  else
  begin
   Caption.setNewTextFormat(Format1);
   Caption.text:='Stop';
   Caption.setTextFormat(0,1,Format2);
   // commande à mettre ici
  end;
 end;
 
Procedure TButton.doKeyDown;
begin
 if (((Key.getAscii=112) or  (Key.getAscii=080)) and  bascule) or (((Key.getAscii=115) or (Key.getAscii=083)) and not bascule)  then doClick;
end;
 
begin
 TButton.Create;
end.
@+