5 Replies Latest reply on Feb 26, 2007 7:29 AM by kglad

    Variables in movie names

    TheScarecrow Level 1
      Ok here is my script :
      I am have this script so that it know what name has been selected and then the movie is supposed to move frames.

      _global.wordList = new Array();
      _global.wordList[0] = "Bedrock";
      _global.wordList[1] = "An";
      function getInfo(word, wordList) {
      switch (_global.word) {
      case 2 :
      currentWord = _global.wordList[_global.word-1];
      count = currentWord.length;
      for (i=1; i<count+1; i++) {
      currentButton = currentWord+i;
      trace(currentButton);
      currentWord.currentButton.gotoAndStop(2);
      //trace("_root."+_global.currentWord+"."+_global.currentButton+".gotoAndStop(2)");
      }
      }
      }

      The part that doesnt work is currentWord.currentButton.gotoAndStop(2); and I dont understand why. I know am trying to use a varialbe. Does anyone know how to fix this or what I am doing wrong. Thanks.
        • 1. Re: Variables in movie names
          kglad Adobe Community Professional & MVP
          1. only prefix your global variables when setting their values, not when retrieving.

          2. use array notation to help flash resolve strings into objects. for example,

          • 2. Re: Variables in movie names
            TheScarecrow Level 1
            ok I did that.. but I still get nothing. Am I doing something else in the code wrong?

            _global.wordList = new Array();
            _global.wordList[0] = "bedrock";
            _global.wordList[1] = "course";
            _global.wordList[2] = "fossil";
            _global.wordList[3] = "hardness";
            _global.wordList[4] = "magma";
            _global.wordList[5] = "rock";
            _global.wordList[6] = "soil";
            _global.wordList[7] = "coal";
            _global.wordList[8] = "extrusive";
            _global.wordList[9] = "glacier";
            _global.wordList[10] = "igneous";
            _global.wordList[11] = "metamorphic";
            _global.wordList[12] = "sand";
            _global.wordList[13] = "structure";
            _global.wordList[14] = "color";
            _global.wordList[15] = "fizz";
            _global.wordList[16] = "gravel";
            _global.wordList[17] = "intrusive";
            _global.wordList[18] = "mineral";
            _global.wordList[19] = "sedimentary";
            _global.wordList[20] = "texture";
            function getInfo(word, wordList) {
            switch (_global.word) {
            case 2 :
            currentWord = _global.wordList[_global.word-1];
            count = currentWord.length;
            for (i=1; i<count+1; i++) {
            currentButton = currentWord+i;
            trace(currentButton);
            this[currentWord][currentButton].gotoAndStop(2);
            trace(this[currentWord][currentButton]);

            }
            }
            }
            • 3. Re: Variables in movie names
              kglad Adobe Community Professional & MVP
              yes, only prefix your variables with _global when you are setting their values, not when you are retrieving them.
              • 4. Re: Variables in movie names
                TheScarecrow Level 1
                I figured it out. Thank you. I appreciate all your help. It works now.
                • 5. Re: Variables in movie names
                  kglad Adobe Community Professional & MVP
                  you're welcome.