6 Replies Latest reply on Aug 23, 2007 1:27 PM by FlashTastic

    Error: Expected a field name after '.' operator

    smohadjer Level 1
      I'm trying to use a "for" loop to add an "onRelease" handler to my symbols using the following code, but I get error that says: Expected a field name after '.' operator. Any idea what's wrong and how I can fix this?

      for (i=1; i<10; i++) {
      thumbs_mc.this["thumb"+i].onRelease = function() {
      // do something
      }

      Thanks
      Saeid
        • 1. Re: Error: Expected a field name after '.' operator
          FlashTastic Level 1
          try

          for(var i=1;i<10;i++){
          thumbs_mc["thumb"+i].onRelease = function(){
          //do something
          }
          }

          Cheers,
          FlashTastic
          • 2. Re: Error: Expected a field name after '.' operator
            smohadjer Level 1
            Thanks so much. It solved the problem.

            Can you explain why this syntax works and the earlier one not?
            • 3. Re: Error: Expected a field name after '.' operator
              FlashTastic Level 1
              Assuming your code is on the main timeline, the usage of this would refer to _root instead of the objects you were trying to access. Since your thumb movieclips are nested inside thumbs_mc, using the array access operators in the corrected code refers to movieclips on the main timeline of thumbs_mc.

              So essentially this is what you were previously targeting:
              _level0.thumbs_mc._level0.thumb1.onRelease = function(){
              //do something
              }

              Cheers,
              FlashTastic

              • 4. Re: Error: Expected a field name after '.' operator
                kay52
                Hi, I was trying to convert my Flash 8 file to Flash Lite 1.1 and came upon an error, like this :

                **Error** Scene=Scene 1, layer=ActionScript, frame=14:Line 3: You must export your movie as Flash 5 to use this action.
                globalStyleFormat.applyChanges("textFont");

                **Error** Scene=Scene 1, layer=ActionScript, frame=14:Line 5: You must export your movie as Flash 5 to use this action.
                x= StartTheQuiz();

                **Error** Scene=Scene 1, layer=ActionScript, frame=14:Line 23: You must export your movie as Flash 5 to use this action.
                PickAnEasyQuestion();

                **Error** Scene=Scene 1, layer=ActionScript, frame=14:Line 28: You must export your movie as Flash 5 to use this action.
                function PickAnEasyQuestion() {

                **Error** Scene=Scene 1, layer=ActionScript, frame=14:Line 96: You must export your movie as Flash 5 to use this action.
                _root.Button1.onRelease = function() {

                **Error** Scene=Scene 1, layer=ActionScript, frame=14:Line 100: You must export your movie as Flash 5 to use this action.
                MoneyGoesUp();

                **Error** Scene=Scene 1, layer=ActionScript, frame=14:Line 102: You must export your movie as Flash 5 to use this action.
                WrongAnswer();

                **Error** Scene=Scene 1, layer=ActionScript, frame=14:Line 106: You must export your movie as Flash 5 to use this action.
                _root.Button2.onRelease = function() {

                **Error** Scene=Scene 1, layer=ActionScript, frame=14:Line 110: You must export your movie as Flash 5 to use this action.
                MoneyGoesUp();

                **Error** Scene=Scene 1, layer=ActionScript, frame=14:Line 112: You must export your movie as Flash 5 to use this action.
                WrongAnswer();

                **Error** Scene=Scene 1, layer=ActionScript, frame=14:Line 116: You must export your movie as Flash 5 to use this action.
                _root.Button3.onRelease = function() {

                **Error** Scene=Scene 1, layer=ActionScript, frame=14:Line 120: You must export your movie as Flash 5 to use this action.
                MoneyGoesUp();

                **Error** Scene=Scene 1, layer=ActionScript, frame=14:Line 122: You must export your movie as Flash 5 to use this action.
                WrongAnswer();

                **Error** Scene=Scene 1, layer=ActionScript, frame=14:Line 126: You must export your movie as Flash 5 to use this action.
                _root.Button4.onRelease = function() {

                **Error** Scene=Scene 1, layer=ActionScript, frame=14:Line 130: You must export your movie as Flash 5 to use this action.
                MoneyGoesUp();

                **Error** Scene=Scene 1, layer=ActionScript, frame=14:Line 132: You must export your movie as Flash 5 to use this action.
                WrongAnswer();

                **Error** Scene=Scene 1, layer=ActionScript, frame=14:Line 137: You must export your movie as Flash 5 to use this action.
                function MoneyGoesUp() {

                **Error** Scene=Scene 1, layer=ActionScript, frame=14:Line 196: You must export your movie as Flash 5 to use this action.
                function WrongAnswer() {

                Total ActionScript Errors: 18 Reported Errors: 18


                I was wondering if you know the solution to this.
                • 5. Re: Error: Expected a field name after '.' operator
                  smohadjer Level 1
                  Thanks for explanation. By the way, even though I don't get error any more my loop is still not working. Here is the code. Any idea why it's not working?

                  for (i=1; i<=5; i++) {
                  thumbs_mc["thumb"+i].onRelease = function() {
                  rendering_mc.attachMovie("rendering"+i,"rendering"+i+"_mc",i);
                  }
                  }
                  • 6. Re: Error: Expected a field name after '.' operator
                    FlashTastic Level 1
                    To use .attachMovie to attach movies to rendering_mc, make sure the linkage names are set on the clips in the library.

                    Right click on your clip in the libray, select Linkage..., check 'Export for actionscript' and give it a name (in this case, the clips you want to attach should be named rendering1, rendering2). Also, the code will only fire if you click on a thumb_mc contained within thumbs_mc.

                    Cheers,
                    FlashTastic

                    P.S. Kay52, if you want an answer, you should start a new post in the forums instead of replying to this post.