3 Replies Latest reply on Aug 20, 2013 2:20 PM by sinious

    Working with word arrays in a game

    Charine -FB buggoop Level 1

      In my spelling game, I have arrays of words that is added to a text field one at a time (through a loop). They are also split into letters so that the player can click on a corresponding letter tile to copy the word. The active letter would be 100% visible (alpha setting )and the other letters would be set to 80%.


      Splitting each word works well it you just want the entire word broken into individual letters, BUT I want my game to be phonics based - so sometimes the sound in a word will have more than one letter e.g. for the word "elephant" the array would be: activeWord:Array = ["e","l","e","ph","a","nt"] and there would of cause be letter tiles with the sound -ph- and -nt- on them to click on too.


      I guess this is where arrays within arrays gets the job done? I have 10 words per level and 30 levels. I will break each word into it's sounds and hardcode each word like I did elephant above.


      How do I rewrite the loop below to accomodate the 10 word loop within a level. After each level I want a score to appear with the option to click next for the next level.


      public var  wordsL1:Array = ["elephant","has","of","off","on","not","got","in","is","it"];

                      private var tf:TextField;

                      public var letterArray:LetterArray;

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


                      // ***constructor code

                      public function WordArray(_tf:TextField)


                          tf = _tf;



                          //**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









                                  //quiz is complete



                          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().


        • 1. Re: Working with word arrays in a game
          sinious Most Valuable Participant

          I'm not the fondest of documentation neglecting questions from people who seem to know their way around but this is always going to come down to reading the selection index and what is around it. You already know it. You can split special match circumstances into an array and match against them before providing a solution but you already seem to know that.

          • 2. Re: Working with word arrays in a game
            Charine -FB buggoop Level 1

            Hi sinious,

            I have never done this before. The code that I have so far was given to me through lost of help in this lovely forum. I just wanted to make sure I was on the right path before I hard code 300 words. Looks like I can proceed?

            Thanks for your confimation. I'll try it and come back if it didn't work

            • 3. Re: Working with word arrays in a game
              sinious Most Valuable Participant

              There's always a better way to do things but ultimately it comes down to if what you're doing works for your audience. If it does, the majority would say you did it correct. After you did it correctly you can spend time optimizing it however you like. If you get down to those specific questions be sure to provide a sample and some code that you think needs optimization and I'm sure we'll be able to help. You're welcome and good luck!