1 Reply Latest reply on May 2, 2009 9:06 AM by kglad

    Functions calling arrays

    Sampad123

      I have 2 arrays set up on one frame:

       

      wordlist = new Array();
      vernacular="hello goodbye yes no thanks";
      wordlist=vernacular.split(' ');

       

      wordlist2 = new Array();
      vernacular2="привет 喂 こんにちは";
      wordlist2=vernacular2.split(' ');

       

      They are separated due to the typeface required to reproduce the Russian and Chinese words in wordlist2 (arial) I am using a different typeface to show the array wordlist.

       

      On a second layer on one frame I have set up the following function, where 'genWord' tells the movie clip 'ltr' to list the array 'wordlist' at certain x and y coordinates:


      function genWord() {
          var gridrez=600/_global.letterSpacing;
         
          var tx=random(Math.ceil(gridrez))*_global.letterSpacing + gridrez/2;
          var ty=random(Math.ceil(gridrez*.6183))*_global.letterSpacing + gridrez/2;
         
          makeAutoFixingWord(wordlist[random(wordlist.length)],tx,ty, 30,30);

       

      }

       

      function makeAutoFixingWord(daword, x, y, resolve, dissolve) {

       

          var kern=0;
         
          for (n=0;n<daword.length;n++) {
              neo="oneletter"+String(depth++);
              this.attachMovie("ltr",neo,depth);
              // position movieclip
              this[neo]._x=x + kern;
              this[neo]._y=y;
              // assign 'real' character for movieclip
              this[neo].realch=daword.substr(n,1);
              this[neo].ch=daword.substr(n,1);
              // set timer
              this[neo].resolve=random(resolve);
              this[neo].dissolve=resolve+dissolve+random(dissolve*2);
              // increment the kern for the next letter
              kern+=_global.letterSpacing;
             
          }

       

      I set up a second movie clip called 'ltr2' (with a diff typeface) and set it within the overall function of 'genWord', but set it to display the contents of the array 'wordlist2', as below. The problem I have is that both movie clips 'ltr' and 'ltr2' are taking there x and y coordinates from the overall function of 'genWord' and appearting directly over the top of each other. When I tried to separate 'makeAutoFixingWord' and 'makeAutoFixingWord2' instructions into their own individual 'genWord' functions, Flash would only recognise one of the functions ('makeAutoFixingWord'). Showing only movie clip 'ltr' and therefore only the array 'wordlist' not 'wordlist2'.

       

      I called the second version of the 'genWord' function 'genWord2' and set it up in exactly the same way on a separate layer frame. With each of the two 'makeAutoFixingWord' instructions and each associated 'ltr' and 'ltr2' movieclip in separate 'genWord' functions, but this obviously isn't the way to do it. Can anyone help?

       


      function genWord() {
          var gridrez=600/_global.letterSpacing;
         
          var tx=random(Math.ceil(gridrez))*_global.letterSpacing + gridrez/2;
          var ty=random(Math.ceil(gridrez*.6183))*_global.letterSpacing + gridrez/2;
         
          makeAutoFixingWord(wordlist[random(wordlist.length)],tx,ty, 30,30);
          makeAutoFixingWord2(wordlist2[random(wordlist2.length)],tx,ty, 10,10);

       

      }

       

      function makeAutoFixingWord(daword, x, y, resolve, dissolve) {

       

          var kern=0;
         
          // create a new ltr movieclip
          for (n=0;n<daword.length;n++) {
              neo="oneletter"+String(depth++);
              this.attachMovie("ltr",neo,depth);
              // position movieclip
              this[neo]._x=x + kern;
              this[neo]._y=y;
              // assign 'real' character for movieclip
              this[neo].realch=daword.substr(n,1);
              this[neo].ch=daword.substr(n,1);
              // set timer
              this[neo].resolve=random(resolve);
              this[neo].dissolve=resolve+dissolve+random(dissolve*2);
              // increment the kern for the next letter
              kern+=_global.letterSpacing;
          }
         
          function makeAutoFixingWord2(daword, x, y, resolve, dissolve) {

       

          var kern=0;
         
          for (n=0;n<daword.length;n++) {
              neo="oneletter"+String(depth++);
              this.attachMovie("ltr2",neo,depth);
              // position movieclip
              this[neo]._x=x + kern;
              this[neo]._y=y;
              // assign 'real' character for movieclip
              this[neo].realch=daword.substr(n,1);
              this[neo].ch=daword.substr(n,1);
              // set timer
              this[neo].resolve=random(resolve);
              this[neo].dissolve=resolve+dissolve+random(dissolve*2);
              // increment the kern for the next letter
              kern+=_global.letterSpacing;
             
          }

       

      }

       

      }