Skip to main content
Known Participant
May 8, 2014
Answered

static textfields

  • May 8, 2014
  • 3 replies
  • 573 views

Hi guys,

I do not know what happens. My input fields do not work and I have no syntax error. I cannot enter data.

This is my code and below my .swf

tks in advance.

package {

  import flash.display.*;

  import flash.text.*;

  import flash.events.MouseEvent;

  public class U1A7_Fidelisation extends MovieClip {

var affichage: String="";

//Déclarer la création du tableau adherents et les varialbes à être utilisés.

  var rang1:Array = [];

  var adherent:Array = [rang1];

  public function U1A7_Fidelisation()

  {

  btnAjouter.addEventListener(MouseEvent.CLICK, ajouter);

  btnAfficher.addEventListener(MouseEvent.CLICK, afficher);

  btnSupprimer.addEventListener(MouseEvent.CLICK, supprimer);

  btnMillesTotale.addEventListener(MouseEvent.CLICK, millesTotale);

//Inclure le fichier externe qui contient la fonction pour caluler les milles accumulés et

//les milles en prime.

  include "U1A7_Milles.as"

  }

  //fonction pour ajouter les renseigments inscrits par l'utilisateur au tableau.

  function ajouter(event:MouseEvent):void

  {

  var nom:String;

  var prenom:String;

      var semaineUne:int;

      var semaineDeux:int;

  var semaineTrois:int;

  var semaineQuatre:int;

  //Extraire les informations nécessaires des champs de saisie.

  prenom = txtPrenom.text;

  nom = txtNom.text;

      semaineUne = int(semaine1.text);

    semaineDeux = int(semaine2.text);

  semaineTrois = int(semaine3.text);

    semaineQuatre = int(semaine4.text);

  adherent.push([prenom, nom, semaineUne, semaineDeux, semaineTrois, semaineQuatre]);

  }

  //fonction pour supprimer les renseigments du tableau.

  function supprimer(event:MouseEvent):void

  {

      var indiceP:int=-1;

      var indiceN:int=-1;

      for (var rang:int = 0; rang < adherent.length; rang++)

      {

        indiceP =(adherent[rang][0].indexOf(txtPrenom.text));

        indiceN =(adherent[rang][1].indexOf(txtNom.text));

        if ((indiceP != -1) && (indiceN != -1)) // prénom et nom ont été repérés.

        {

          adherent.splice(rang,1);  // rang - indique la rangée à supprimer.

    // 1 - indique de supprimer cette rangée seulement.

        }

      }

    }

  //fonction pour afficher afin que tout les renseignements inscrits dans le tableau

  //deviennent visibles.

  function afficher (event:MouseEvent):void

  {

  affichage=("");

  for (var rang:int = 0; rang < adherent.length; rang++)

  {

  for (var col:int = 0; col < adherent[0].length; col++)

  {

  affichage = affichage + " " + adherent[rang][col];

  }

  affichage = affichage + "\n";

  }

  monMessage.text = affichage;

  txtPrenom.text = "";

  txtNom.text = "";

  semaine1.text = "";

  semaine2.text = "";

  semaine3.text = "";

  semaine4.text = "";

  }

  //fonction pour calculer le total de points(milles) accumulés en 4 semaines d'un client

  //et pour voir si ils obtiendront des milles en prime.

  function millesTotale(event:MouseEvent):void

  {

   var prenom2:String;

      var nom2:String;

      var semaineUne2:int;

      var semaineDeux2:int;

   var semaineTrois2:int;

   var semaineQuatre2:int;

  

   var somme:int;

   var sommeMessage:String;

  

   affichage = "";

     

      prenom2 = txtPrenom.text;

   nom2 = txtNom.text;

      semaineUne2 = int(semaine1.text);

   semaineDeux2 = int(semaine2.text);

   semaineTrois2 = int(semaine3.text);

   semaineQuatre2 = int(semaine4.text);

     

      somme = (semaineUne2 + semaineDeux2 + semaineTrois2 + semaineQuatre2);

  

     if (somme >= 5000)

  {

  sommeMessage ="1000";

  }

  else if (somme < 5000)

  {

  sommeMessage ="0";

  }

  

   affichage = (prenom2 + nom2 + " a accumulé " + somme + " milles. Elle/Il a obtenu "  + sommeMessage + " mille(s) en prime.");

  //Afficher le message dans le champ de saisie monMessage. 

   monMessage.text = affichage;

  

  txtPrenom.text = "";

  txtNom.text = "";

  semaine1.text = "";

  semaine2.text = "";

  semaine3.text = "";

  semaine4.text = "";

  }

  }

This topic has been closed for replies.
Correct answer Ned Murphy

Unfortunately I can't translate your code into English to better understand it, but I see you are resetting the various textfields in mutliple functions, so I would first suspect that your code is resetting them anytime you try to use them.

3 replies

ORDIYOHAuthor
Known Participant
May 8, 2014

Tks Ned.

Have a great one.

kglad
Community Expert
Community Expert
May 8, 2014

double check (in the properties panel) that those are input textfields.

if they are and are not selectable, you have something overlying them.

ORDIYOHAuthor
Known Participant
May 8, 2014

ok, i'm looking at it.

but everything is ok in the properties.

Tks.

kglad
Community Expert
Community Expert
May 8, 2014

can you see your cursor when you click on an input textfield?

if no, there's something overlying it.  if yes, what happens when you type a letter and number?

p.s.  make sure the font color is NOT white, and you should embed your font.

p.p.s.  i just saw you marked ned's response 'correct'.  i don't see any change listeners where that could occur.  you have click listeners but those wouldn't change any textfields unless something is clicked.

Ned Murphy
Ned MurphyCorrect answer
Legend
May 8, 2014

Unfortunately I can't translate your code into English to better understand it, but I see you are resetting the various textfields in mutliple functions, so I would first suspect that your code is resetting them anytime you try to use them.