6 Replies Latest reply on Oct 20, 2009 1:10 PM by erthy

    Passing a variable between functions [Silly Question]

    erthy Level 1

      Hey, I am trying to write a program (who wouldve guessed) and I have the following problem. I set a variable in one function, but when I access it from another one, it is "undefined". How can I pass the variable, so both the functions see it? I thought the "public" class when defining a function should take care of that, but I was obviously wrong. Please help? (Code following...)

       

      public function dalsi_slovicko():void {

                     var pocet_slovicek = slovnikXML.slovicka.elements("*").length();

                     var cislo_slovicka = randomNumber(0, pocet_slovicek);

                     var slovicko_1 = ask(cislo_slovicka, "en");

                     var slovicko_2 = ask(cislo_slovicka, "cs");

                     slovicko1.text = slovicko_1;

                }

      private function kontrola() : void {

                if (nazor.text == slovicko_2) {

                      dalsi_slovicko()

                }     

                else {

                     Alert.show("Špatně!! \n Slovicko_2 bylo:" + slovicko_2);

                }

                  }

      Thanks...