5 Replies Latest reply on Aug 26, 2013 2:44 PM by Ned Murphy

    Help with nested arrays please

    Charine -FB buggoop Level 1

      I'm struggling to set the levels of my word game up correctly.

      I have 30 levels


      var wordLevels:Array = [wordsL01,wordsL02,wordsL03,wordsL04,wordsL05,wordsL06,wordsL07,wordsL08,wordsL09,wordsL1 0,

                                                      wordsL11,wordsL12,wordsL13,wordsL14,wordsL15,wordsL16,wordsL17,wordsL18,wordsL19,wordsL20 ,

                                                      wordsL21,wordsL22,wordsL23,wordsL24,wordsL25,wordsL26,wordsL27,wordsL28,wordsL29,wordsL30 ]


      Each level has 10 words


           public var  wordsL01:Array = [wordsL1W1,wordsL1W2,wordsL1W3,wordsL1W4,wordsL1W5,wordsL1W6,wordsL1W7,wordsL1W8,wordsL1W 9,wordsL1W10];


      Each word is split up into sounds.


           public var  wordsL2W9:Array = ["th","r","ee"];


      I want to display the score etc after each level. I think to do this I will have to write a loop to generate the ten words in a active level and then after each level has been completed show the score etc. before it goes to the next level.


      I tried to write the loop for this (see code below), but instead of it tracing the 10 words I expected, I got the following in the output pannel: function Function() {}


      What did I do wrong in my code? I marked the relevant bits in red:




          import flash.display.MovieClip;

          import flash.text.TextField;

          import flash.events.Event;   

          import flash.utils.Timer;

          import flash.events.*;

          //import flash.events.MouseEvent;


          public  dynamic class WordArray extends MovieClip


                      public var wordtext:wordText =  new wordText;

                      var activeWordArray:Array;

                      var activeLevelofTenWordsArray:Array;

                      public var  wordsL1:Array = ["elephant","has","of","off","on","not","got","in","is","it"]; //this was for testing only, to be removed as soon as al levels can be broken up.



      public var  wordsL1W1:Array = ["a"];

      public var  wordsL1W2:Array = ["h","a","s"];

      public var  wordsL1W3:Array = ["o","f"];

      public var  wordsL1W4:Array = ["o","f","f"];

      public var  wordsL1W5:Array = ["o","n"];  // an so on up to wordsL30W10:


      public var  wordsL01:Array = [wordsL1W1,wordsL1W2,wordsL1W3,wordsL1W4,wordsL1W5,wordsL1W6,wordsL1W7,wordsL1W8,wordsL1W 9,wordsL1W10];

      public var  wordsL02 //etc up to wordsL30.


      public var wordLevels:Array = [wordsL01,wordsL02,wordsL03,wordsL04,wordsL05,wordsL06,wordsL07,wordsL08,wordsL09,wordsL1 0,

                                                      wordsL11,wordsL12,wordsL13,wordsL14,wordsL15,wordsL16,wordsL17,wordsL18,wordsL19,wordsL20 ,

                                                      wordsL21,wordsL22,wordsL23,wordsL24,wordsL25,wordsL26,wordsL27,wordsL28,wordsL29,wordsL30 ]


                      private var tf:TextField;

                      public var letterArray:LetterArray;

                      public var tileTimer = new Timer(500,384);



                      // ***constructor code

                      public function WordArray(_tf:TextField)


                          tf = _tf;




                      function levelGenerator():void


                          //**To get next level of 10 words



                              activeLevelofTenWords();// to get next word



                              trace("Level generator is working");




                          //Game is complete




                      function activeLevelofTenWords():void


                          activeLevelofTenWordsArray = wordLevels.shift();//should I add a split here?

                          trace("Placemark for active level of ten words to follow directly");



                     //worked up to here, next steps and tests to follow   




                      function runTiles():void


                          //**Run letter Tiles Start**//

                          //letterArray = new LetterArray();



                          //tileTimer.addEventListener(TimerEvent.TIMER, gameLoop);



                          /*public function gameLoop(timerEvent:TimerEvent):void


                              trace("Tile Timer Started");







                      function nextWordF():void









                          private function activeWordF():void


                              activeWordArray = wordsL1.shift().split("");

                               // this array needs to be passed to the class that checks which letters are clicked (or used in this class if that's where the clicked letters are handled) so the clicked letters can be compared to activeWordArray's elements.   

                              // when the clicked letters are completed for this word, call nextWordF().



                              public function populateMyWordBox()


                                  //trace("place my word box is working");




                                  tf.text = activeWordArray.join("");