20 Replies Latest reply on Jan 12, 2007 4:14 AM by uxk8396

    Global Score NOT FUNCTIONING

    uxk8396

      Hello:
      My score does not appear at all in the score box (dynamic text field) referenced as insert_txt.text when I press the submit button, even if I give the correct or wrong answer.

      "myScore" is referenced as the var



      I performed a trace ("clik") and the button seems to be working properly.

      Please help.
        • 1. Global Score NOT FUNCTIONING
          cinemaguy Level 1
          I am not sure why you are declaring the score as a global variable but Try this...
          • 2. Re: Global Score NOT FUNCTIONING
            Level 7
            > _global.myScore = 0;

            good

            > myScore += 5;

            You didn't put the "_global." there .. there will mean it will create a new
            local variable called 'myScore' which will hide the global one.
            --
            Jeckyl


            • 3. Re: Global Score NOT FUNCTIONING
              Level 7
              Oh, and this:

              > } else {
              > myScore += 0;

              is just a waste of script .. it has no effect, but will take time to
              execute. Best remove it.
              --
              Jeckyl


              • 4. Re: Global Score NOT FUNCTIONING
                uxk8396 Level 1
                Hi :
                (a)The code that you supplied have the following problems:
                After typing the correct answer (which is lascaux), I obtain 5 points, but it does not appear into my
                score box(instance name: myScore_txt and var is myScore). The score appears next to lascaux like this: (lascaux5)
                Please note: the score field is a dynamic text field. And the instance name of the input text field is "insert_txt"
                Please clarify how to make the score appears in the score box.

                (b) When I continue clicking on the submit button, the score gets on adding (5 10 15 20..) in teh insert_txt box.
                I do not want the score to appear in the insert_txt box. It shouldn't.
                I replaced the insert_txt by myScore_txt in the codes, but nothing appears.

                Please advise.
                • 5. Re: Global Score NOT FUNCTIONING
                  Level 7
                  You obviously didn't read my reply, as your code is still incorrect

                  > myScore += 15;

                  you need (as i said before)

                  _global.myScore += 15;

                  > myScore += 5;

                  and here you need

                  _global.myScore += 5;
                  --
                  Jeckyl


                  • 6. Re: Global Score NOT FUNCTIONING
                    uxk8396 Level 1
                    Jeckyl,
                    I did take your comments into consideration but it did not make any difference when I ckicked the submit_btn. Nothing appeared in the score box either.

                    I did replace myScore by _global.myScore in the codes below. But still it did not work. I tried various options as well. Can you please check (by doing a test) whether the codes are working properly on your side.

                    Thanks
                    U
                    • 7. Re: Global Score NOT FUNCTIONING
                      Level 7
                      > _global.myScore = 0;
                      > submit_btn.onRelease = function() {
                      > var tempString:String = _root.insert_txt.text;
                      > if (tempString.toLowerCase() == "lascaux") {
                      > myScore += 15;
                      > //I replaced insert_txt by myScore_txt hoping to see the score in the
                      > score
                      > box???
                      > _root.myScore_txt.text += myScore;
                      > trace ("gogot")
                      > } else {
                      > myScore += 5;
                      > _root.insert_txt.text += myScore;
                      > }
                      > };

                      The above code makes no sense at all and is MUCH worse than the original you
                      posted.

                      The only problem with your original code was that you did not prefix
                      "_global." when you updated the score.

                      Of course, you do not show anywhere there how you display the value of
                      myScore in the dynamic text box .. which is most likely where your problem
                      is, as the code you ORIGINALLY provided was the correct logic for updating
                      the score (once fixed to include the "_global." prefix.
                      --
                      Jeckyl



                      • 8. Re: Global Score NOT FUNCTIONING
                        Level 7
                        > Jeckyl,
                        > I did take your comments into consideration but it did not make any
                        > difference
                        > when I ckicked the submit_btn. Nothing appeared in the score box either.

                        Your existing code WILL NOT WORK because it is not prefixing the _global.

                        So you will not have any solution that works using a global score variable
                        until you do so.

                        It is quite possible that you have other problems in your movie, but unless
                        you provide a FLA that we can look at, we can only fix the problem in the
                        script you supply.
                        --
                        Jeckyl


                        • 9. Re: Global Score NOT FUNCTIONING
                          uxk8396 Level 1
                          Hi Jeckyl,
                          That is very nice of you to be willing to very the FLA. Where and how do I send you my FLA?

                          Thanks
                          U
                          • 10. Re: Global Score NOT FUNCTIONING
                            uxk8396 Level 1
                            Hi Jeckyl,
                            That is very nice of you to be willing to verify the FLA. I am going crazy working with the same code for so many days and the core of the concept relies on the scores. Where and how do I send you my FLA?

                            Thanks
                            U
                            • 11. Re: Global Score NOT FUNCTIONING
                              Level 7
                              Best to upload it somewhere and post the URL for a link to it so I (or
                              anyone else who wants to help) can download it
                              --
                              Jeckyl


                              • 12. Global Score NOT FUNCTIONING
                                uxk8396 Level 1
                                The score problem was solved when I deleted a graphic layer from fla file. I do not understand how a graphic is conflicting with the score.

                                Any guess!
                                • 13. Re: Global Score NOT FUNCTIONING
                                  Level 7
                                  Pretty much what I suspected.

                                  You have associated a text fields with the name 'myScore' which will make a
                                  timeline variable of that name, and so masks the global.

                                  You should some other name for the associated variable, and copy from
                                  myScore (the global) to that variable .. or (probably better) instead of
                                  using an associated variable, copy myScore directly into the
                                  myScore_txt.text. Probably just after you modify the value of
                                  _global.myScore
                                  --
                                  Jeckyl


                                  • 14. Re: Global Score NOT FUNCTIONING
                                    uxk8396 Level 1

                                    I am not clear about what I should change.
                                    Kindly specify clearly which instance name and var I should change, for the score field (dynamic) and the input field.
                                    Can you note down the changes in the coding so that I have a better idea.

                                    Thanks
                                    U
                                    • 15. Re: Global Score NOT FUNCTIONING
                                      Level 7
                                      > Kindly specify clearly which instance name and var I should change, for
                                      > the
                                      > score field (dynamic) and the input field.

                                      Its up to you on how you want ot do it. If I do it for you you won't really
                                      know what's going on.

                                      You problem is that you have associated the variable myScore with the
                                      myScore_txt. That doesn't work for global variables.

                                      Instead, when you change the value of _global.myScore also set
                                      myScore_txt.text = _global.myScore;

                                      eg
                                      change your original

                                      >>
                                      myScore += 5;
                                      trace("clik")
                                      >>
                                      into
                                      >>
                                      _global.myScore += 5;
                                      myScore_txt.text = _global.myScore;
                                      trace("clik")
                                      >>

                                      similar elsewhere where you modify the value of myScore.
                                      --
                                      Jeckyl


                                      • 16. Re: Global Score NOT FUNCTIONING
                                        uxk8396 Level 1
                                        I added the line (myScore_txt.text = _global.myScore;)
                                        with all the score values but it is still NOT working.
                                        What should I do now??

                                        __________________

                                        stop();
                                        //set the inital score
                                        _global.myScore = 0;
                                        _root.myScore_txt.text = _global.myScore;
                                        //
                                        //Making use of the submit button (1st option)
                                        _root.submit_btn.onRelease = function() {
                                        if (_root.insert_txt.text == "lascaux" || _root.insert_txt.text == "Lascaux") {
                                        _global.myScore += 5;
                                        _root.myScore_txt.text = myScore;

                                        //_root.gotoAndStop("Right1")
                                        trace("gogot");
                                        } else {
                                        _global.myScore += 0;
                                        _root.myScore_txt.text = _global.myScore;

                                        //_root.gotoAndStop("Wrong1");
                                        }
                                        };

                                        • 17. Re: Global Score NOT FUNCTIONING
                                          Level 7
                                          did you remove the var associated with myScore_txt ?

                                          "uxk8396" <webforumsuser@macromedia.com> wrote in message
                                          news:eo4ir1$rgr$1@forums.macromedia.com...
                                          >I added the line (myScore_txt.text = _global.myScore;)
                                          > with all the score values but it is still NOT working.
                                          > What should I do now??
                                          >
                                          > __________________
                                          >
                                          > stop();
                                          > //set the inital score
                                          > _global.myScore = 0;
                                          > _root.myScore_txt.text = _global.myScore;
                                          > //
                                          > //Making use of the submit button (1st option)
                                          > _root.submit_btn.onRelease = function() {
                                          > if (_root.insert_txt.text == "lascaux" || _root.insert_txt.text ==
                                          > "Lascaux")
                                          > {
                                          > _global.myScore += 5;
                                          > _root.myScore_txt.text = myScore;
                                          >
                                          > //_root.gotoAndStop("Right1")
                                          > trace("gogot");
                                          > } else {
                                          > _global.myScore += 0;
                                          > _root.myScore_txt.text = _global.myScore;
                                          >
                                          > //_root.gotoAndStop("Wrong1");
                                          > }
                                          > };
                                          >
                                          >
                                          >


                                          • 18. Global Score NOT FUNCTIONING
                                            uxk8396 Level 1
                                            Jeckyl:
                                            You mean to delete the name assigned for the var of the score field in the properties (that is originally "myScore"). I tried that also but in vain.

                                            Since you have the FLA file, can you please check it out if it works after whatever amendments you are suggesting.
                                            Kindly come up with a real solution. It is driving me crazy!

                                            Thanks again
                                            U
                                            • 19. Re: Global Score NOT FUNCTIONING
                                              Level 7
                                              You've got several problems.

                                              First .. you have multiple myScore_txt objects because you have separate
                                              keyframes in the score layer.

                                              Remove the extras so there is just the one keyframe there .. and then remove
                                              the associated var for myScore_txt so it is NOT myScore

                                              Then every method that changes _global.myScore should also copy it into
                                              myScore_txt.text

                                              NOTE: From what you have there, it doesn't look like it really has to be a
                                              global variable .. it can just be a timeline variable.

                                              In that case, using the associated variable is fine, and you do not need to
                                              copy myScore into it all the time.
                                              --
                                              Jeckyl


                                              • 20. Re: Global Score NOT FUNCTIONING
                                                uxk8396 Level 1

                                                The score problem was solved when I deleted a graphic layer from fla file. I do not understand how a graphic is conflicting with the score. I removed the extra keyframes as you suggested and changed the name of the va to be Score and keeping the same instance name of myScore_txt
                                                Adding the line did not help as the scores appeared like 51015.. Thanks jeckyl to be patient with me.

                                                Any guess why the graphic layer was in total conflict with the score field!
                                                U