8 Replies Latest reply on Jun 7, 2006 11:02 PM by orangesquirrel

    Displaying a variable

    orangesquirrel
      I have variables for each players score as global variables
      and i was wondering how to display them on the game board
      in text boxes
      if it's possible?

      thanks,
      Aaron
        • 1. Re: Displaying a variable
          Craig Grummitt Level 3
          Look up dynamic text boxes
          • 2. Re: Displaying a variable
            orangesquirrel Level 1
            Thanks
            just one problem
            the games played works, displaying how many games have been played
            but the score ones dont show the new score until you click on the text with the mouse
            i'm not sure why
            both the variables are changed at the same time
            and both the dynamic text box settings are the same (except for the instance names and the variables)

            any help?
            aaron
            • 3. Re: Displaying a variable
              Craig Grummitt Level 3
              can't think of any reason off the top of my head why that would be happening. i'm sure there's a crucial piece of information missing though, that would hit me in the head if i could see the source code.(fla)
              • 4. Re: Displaying a variable
                orangesquirrel Level 1
                I've uploaded the whole file so you can see all the code, as the problem could be anywhere

                thanks alot,
                aaron
                • 5. Re: Displaying a variable
                  Craig Grummitt Level 3
                  Wow i just thought i'd have a wade through your code and found myself doing dog-paddle! After working out how to replicate your error by making the game think i'd won a game(i worked out i had to get all three across the top right with the first square last) i then experimented with a few changes that i thought might be causing problems:

                  i removed the dynamic textboxes from the graphics they were in - i don't think this is a very good idea as they would not be able to be targetted - if they need to be inside a symbol best to put them in a movie-clip.

                  i embedded font symbols(just numbers) - ideally you would do this if you've selected anti-alias for animation.

                  i removed the instance names for the text fields as they were the same names as the variables contained within the text fields which could cause conflicts.
                  but the winner appeared to be: i changed all your global variables to _root. in doing so i found several places where you had referenced local variables where i believe you meant to reference global variables. i don't know exactly what the problem was but i know it was when i reached this stage the problem resolved itself and the dynamic text boxes updated correctly. i'm not very familiar with global variables and text boxes as i rarely use global variables - i believe it's not best coding practice to use them(as it is to use _root as well, incidentally. but when you're learning best practice may not be that important i guess!)

                  hopefully this helps
                  craig
                  • 6. Re: Displaying a variable
                    orangesquirrel Level 1
                    Yeah, sorry about the mess. When i started this game, i knew nothing about actionscript, and only the tiniest about flash, so thats my excuse

                    Thanks alot for the tips, i've fixed them all, and its working fine now
                    sorry about forgetting to tell you that its only coded for when the top three squares win

                    but just to be extra annoying, i have one more question
                    is there, any way, to have an if statement, with three conditions, where any one can count
                    ie, for eg,
                    if (a=1) or (b=1) or (c=1) {
                    statement
                    }
                    is that possible?

                    thanks heaps for your help,
                    you are definately going into the credits,
                    aaron
                    • 7. Re: Displaying a variable
                      Level 7
                      > if (a=1) or (b=1) or (c=1) {
                      > statement
                      > }

                      firstly use == to compare things instead of = (which sets a new value)

                      And you need ( ) around the whole condition so

                      Also best to use '||' instead of 'or' ('or' is deprecated old syntax)

                      if ( (a == 1) || (b == 1) || (c ==1) ) {
                      statement
                      }

                      and you don't strictly need the ( ) around each test, so can simplify as

                      if (a == 1 || b == 1 || c ==1) {
                      statement
                      }
                      --
                      Jeckyl


                      • 8. Re: Displaying a variable
                        orangesquirrel Level 1
                        Thanks alot
                        hopefully this is the last hurdle ill have