IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Flash Pascal Discussion :

Une variante checkbox


Sujet :

Flash Pascal

  1. #1
    Membre chevronné
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2005
    Messages
    1 644
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 644
    Points : 1 975
    Points
    1 975
    Par défaut Une variante checkbox
    Plus propre au niveau visuel mais très bidouille au niveau du code.

    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
     
    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 : 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
     
    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 Fichiers attachés

Discussions similaires

  1. une certaine checkbox désactive d'autres champs
    Par fred036 dans le forum Général JavaScript
    Réponses: 15
    Dernier message: 05/10/2006, 15h19
  2. [CF][PPC/VB.NET/Datagrid] Comment gérer une colonne CheckBox ?
    Par joefou dans le forum Windows Mobile
    Réponses: 5
    Dernier message: 28/08/2006, 17h08
  3. Réponses: 3
    Dernier message: 26/07/2006, 10h18
  4. Réponses: 2
    Dernier message: 19/05/2006, 18h01
  5. décocher une checkbox en cochant une autre checkbox
    Par psychoBob dans le forum Général JavaScript
    Réponses: 25
    Dernier message: 22/11/2005, 15h48

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo