Question

I have a function that gathers input information from a flash template. I want this information to be stored into an array. I try to use the push function but I don't know how to push more than one value into a new array ex: array.push(1);. Ì'm currently taking an online class and this was never clarified. Here is the code that I have in place:This first part is the function that displays all the arrays and their contents.

      function afficher(event:MouseEvent):void 
  {
    affichage="";
    for (var i=0; i<voyageur.length; i++)
    {
        affichage = affichage + (voyageur[i][0] + " " + voyageur[i][1] + " : " + voyageur[i][2] + ", " + voyageur[i][3] + ", " + voyageur[i][4] + ", " + voyageur[i][5] + "." +  "\n");
    }
    message_txt.text = affichage;

  }

This function serves to add the retrieved information from the input fields from my flash program into an array called "voyageur".

function ajouter(event:MouseEvent):void 
      {
        // Declare variables to hold the input (integer) value
        var prenomSaisi:String;
        var nomSaisi:String;
        var semaine1Saisi:String;
        var semaine2Saisi:String;
        var semaine3Saisi:String;
        var semaine4Saisi:String;
        var entier1:int;
        var entier2:int;
        var entier3:int;
        var entier4:int;

        // Lire le texte du champ de saisie et le stocker dans une variable String.
        prenomSaisi=(boitePrenom.text);
        nomSaisi=(boiteNom.text);
        semaine1Saisi=(boiteSemaine1.text);
        semaine2Saisi=(boiteSemaine2.text);
        semaine3Saisi=(boiteSemaine3.text);
        semaine4Saisi=(boiteSemaine4.text);

        // Convertir la chaîne de caractères saisie (String) en un entier (int).
        entier1=int(semaine1Saisi);
        entier2=int(semaine2Saisi);
        entier3=int(semaine3Saisi);
        entier4=int(semaine4Saisi);

        // Ajouter le nouvel entier à la fin du tableau.
        *voyageur.push(prenomSaisi, nomSaisi, entier1, entier2, entier3, entier4);*(This is what I need help with)

      }

My display function "afficher" works fine but as soon as I add a new client with my push, my display function ceases to work and I get an error.

Was it helpful?

Solution

push an array instead of 6 items!

voyageur.push([prenomSaisi, nomSaisi, entier1, entier2, entier3, entier4]);

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top