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
 
Outils de la discussion
Publicité
'
Vieux 01/07/2012, 18h24   #1
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
Par défaut Une variante checkbox

Plus propre au niveau visuel mais très bidouille au niveau du code.

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
 
unit UCheckbox;
 
interface
 
uses Flash8;
 
Const c=10;//côté du tick
      ox=5;// pour centrer par rapport au texte
      oy=3;//idem
type
  TTick=class(movieclip)
   checked:Boolean;
   procedure onPress;
   procedure onEnterFrame;
   constructor Create(AOWNER:movieclip);
  end;
 
 TCheckBox=Class(movieclip)
  checked:Boolean;
  Font:TextFormat;
  Caption:TextField;
  Tick:TTick;
  constructor Create(AOWNER:movieclip);
 end;
 
 
implementation
 
constructor TTick.create(AOWNER:movieclip);
begin
 inherited create(AOWNER,'Tick',0);  //pour la zone onPress
 beginFill(clwhite);       //opaquebackground ne définit pas la zone
 moveto(ox-c/2,oy-c/2);
 lineto(ox-c/2,oy+c/2);
 lineto(ox+c/2,oy+c/2);
 lineto(ox+c/2,oy-c/2);
 lineto(ox-c/2,oy-c/2);
 EndFill();
 
 linestyle(1,$A1A1A1);
 moveto(c/2+ox,-c/2+oy);
 lineto(-c/2+ox,-c/2+oy);
 lineto(-c/2+ox,c/2+oy);
 linestyle(1,clwhite);
 moveto(-c/2+ox,c/2+oy);
 lineto(c/2+ox,c/2+oy);
 lineto(c/2+ox,-c/2+oy);
 linestyle(1,$696969);
 moveto(9*c/20+ox,-2*c/5+oy);
 lineto(-2*c/5+ox,-2*c/5+oy);
 lineto(-2*c/5+ox,9*c/20+oy);
 linestyle(1,$E3E3E3);
 moveto(-2*c/5+ox,9*c/20+oy);
 lineto(-2*c/5+ox,9*c/20+oy);
 lineto(-2*c/5+ox,9*c/20+oy);
 checked:=false;
end;
 
constructor TCheckBox.Create(AOWNER:movieclip);
begin
 inherited Create(AOWNER,'CheckBox',AOWNER.getNextHighestDepth);
 Tick:=TTick.Create(self);
 Tick._x:=0;
 Tick._y:=0;
 Font := TextFormat.Create('Arial',14,ClBlack,false,false,false,'','','left');
 Caption:=TextField.Create(Self, '',1,15,-6,100,20);
 Caption.SetNewTextFormat(Font);
 Caption.text:='CheckBox';
 Checked:=false;
end;
 
procedure TTick.onPress;
begin
  TCheckBox(_parent).Checked:=true;
end;
 
Procedure TTick.onEnterFrame;
begin
 if checked = TCheckBox(_parent).checked then exit;
 checked := not checked;
 
 if checked then
 begin
  linestyle(2,clblack);
  BeginFill(clBlack);
  moveto(ox-c/5,oy-c/5);
  lineto(ox+c/5,oy+c/5);
  moveto(ox-c/5,oy+c/5);
  lineto(ox+c/5,oy-c/5);
 end else
 begin
  BeginFill(clWhite);
  linestyle(2,clwhite);
  moveto(ox-c/5,oy-c/5);
  lineto(ox+c/5,oy+c/5);
  moveto(ox-c/5,oy+c/5);
  lineto(ox+c/5,oy-c/5);
 end;
end;
 
end.
programme :
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
 
program PCheckbox;
 
{$FRAME_WIDTH 550}
{$FRAME_HEIGHT 400}
{$FRAME_RATE 32}
{$BACKGROUND $f0f0f0}
 
uses
  Flash8,UCheckbox;
type
 
   Essai=class(movieClip)
     current:number;
     check1,check2:TCheckbox;
     Field:TextField;
     MyFont:Textformat;
     Procedure onEnterFrame;
     Constructor Create;
   end;
 
Constructor Essai.Create;
begin
 inherited create(nil,'essai',0);
 check1:=TCheckBox.create(self);
 with check1 do
 begin
  _x:=100;
  _y:=100;
  caption.text:='Affichage n°1';
 end;
 
 check2:=TCheckBox.create(self);
 with check2 do
 begin
  _x:=100;
  _y:=120;
  caption.text:='Affichage n°2';
 end;
 
  MyFont:= TextFormat.Create('Arial', 25, $000000,true,false,false);
  Field :=TextField.Create(self, '',2, 10,150,450,40);
  Field.setNewTextFormat(MyFont);
  current:=0;
end;
 
Procedure Essai.onEnterFrame;
begin
if Check1.checked and (current <> 1) then
 begin
   current := 1;
   check2.checked:=false;
   Field.text:="j'ai pressé sur le premier checkbox";
 end else
 if check2.checked and (current <> 2) then
 begin
   current := 2;
   check1.checked:=false;
   Field.text:="j'ai pressé sur le second checkbox";
 end;
end;
 
begin
 essai.create;
end.
Fichiers attachés
Type de fichier : swf PCheckbox.swf (1,0 Ko, 2 affichages)
__________________
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
Réponse
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 02h00.


 
 
 
 
Partenaires

Hébergement Web