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 :

Type énuméré


Sujet :

Flash Pascal

  1. #1
    Membre chevronné
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    April 2005
    Messages
    1 641
    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 : April 2005
    Messages : 1 641
    Points : 1 968
    Points
    1 968
    Par défaut Type énuméré
    Voilà, j'ai tenté de faire un Tlabel façon delphi pour caché au maximum l'actionscript... Peut-être que cette voie permettrait de voir venir davantage de personnes sur ce forum...

    ci-joint mon code :

    La gestion de la font

    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.
    le label :

    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
     
    unit ULabel;
     
    interface
     
    uses Flash8,UFont;
     
    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;
     
     
    implementation
     
    Constructor TLabel.Create(parent:movieclip);
    begin
     FTextfield:=TextField.Create(Parent,'',parent.getNextHighestDepth(),0,0,100,100);
     Font:=TFont.Create;
     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;
     
    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
     
    program Project1;
     
    {$FRAME_WIDTH 550}
    {$FRAME_HEIGHT 400}
    {$FRAME_RATE 12}
    {$BACKGROUND $FFFFFF}
     
    uses
      Flash8,ULabel;
     
     
    var label1:Tlabel;
     
    begin
     label1:=TLabel.create(_root);
     with label1 do
     begin
      border:=true;
      font.name:='arial';
      font.size:=40;
     // font.style:=[fsBold,fsUnderline];
      font.bold:=true;
      font.color:=clred;
      font.underline:=true;
      caption:="ça marche";
      autosize:=true;
      left:=170;
      top:=100;
     end;
     
     
    end.
    Ma question : le code mis en commentaire ne fonctionne pas.
    la syntaxe : montype = (.....,.....,.....) ne passe pas.

    Dommage, au lieu de créer des propriétés séparées pour bold, italic, underline, le Fontstyle était bien pratique et conforme à la notation delphi.

    Le type variant peut sans doute me dépanner sur ce coup là ?

    Anthony

  2. #2
    Expert éminent sénior
    Avatar de Paul TOTH
    Homme Profil pro
    Freelance
    Inscrit en
    November 2002
    Messages
    8 964
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Freelance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : November 2002
    Messages : 8 964
    Points : 28 427
    Points
    28 427
    Par défaut
    à faire en effet

    non le variant ne changera pas grand chose, en fait un type énuméré ce sont juste des alias de constantes numériques.
    Developpez.com: Mes articles, forum FlashPascal
    Entreprise: Execute SARL
    Le Store Excute Store

  3. #3
    Membre chevronné
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    April 2005
    Messages
    1 641
    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 : April 2005
    Messages : 1 641
    Points : 1 968
    Points
    1 968
    Par défaut
    Oui, ce serait sympa... C'est utile

    Difficile de s'en passer.

    merci pour ta réponse

    A+

  4. #4
    Expert éminent sénior
    Avatar de Paul TOTH
    Homme Profil pro
    Freelance
    Inscrit en
    November 2002
    Messages
    8 964
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Freelance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : November 2002
    Messages : 8 964
    Points : 28 427
    Points
    28 427
    Par défaut
    hum...pas simple à mettre en place...je verrais plus tard
    Developpez.com: Mes articles, forum FlashPascal
    Entreprise: Execute SARL
    Le Store Excute Store

  5. #5
    Membre chevronné
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    April 2005
    Messages
    1 641
    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 : April 2005
    Messages : 1 641
    Points : 1 968
    Points
    1 968
    Par défaut
    Citation Envoyé par Paul TOTH Voir le message
    hum...pas simple à mettre en place...je verrais plus tard
    Je me doute...Rien ne presse.

    Bonne journée

Discussions similaires

  1. Questions sur les types énumérés
    Par Premium dans le forum Langage
    Réponses: 5
    Dernier message: 12/11/2006, 19h00
  2. [c# 2.0][DEBUTANT] type énuméré
    Par dsr57 dans le forum C#
    Réponses: 2
    Dernier message: 13/10/2006, 17h03
  3. [D2005] Utilisation des types énumérés
    Par bouha dans le forum Delphi .NET
    Réponses: 2
    Dernier message: 21/07/2005, 23h21
  4. Réponses: 7
    Dernier message: 02/06/2003, 09h38
  5. Transformer un caractère en type énuméré
    Par HT dans le forum Langage
    Réponses: 3
    Dernier message: 22/10/2002, 21h46

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