6 Replies Latest reply on Nov 10, 2009 10:51 AM by Ned Murphy

    Displaying a variable on stage problem

    rowancavanagh

      I've got a Global variable here in my flash project, which is stated like this, _global.swfloaded = "home";

       

      This variable then changes throughout the project, depending on what buttons are pushed.

      One example of the change is when a button labelled Classic is clicked, taking the user to the Classic page, the variable is changed like this - swfloaded = "classic";

       

      I then have a dynamic text field with the instance name of 'output' on the stage, which I want to display the variable, the code I've used for that is - output.text = swfloaded;

       

      The problem is the 'output' field doesn't update at all, no matter what is clicked.

       

      Does anyone know how I can quickly and easily get the field to update when the global variable itself is changed.

       

      Cheers

        • 1. Re: Displaying a variable on stage problem
          Ned Murphy Adobe Community Professional & MVP

          Whenever I used _global variables I found that continuing to use the lead-in of _global helped keep things working.  So in your case, where you say you used: swfloaded = "classic";,  I would have used: _global.swfloaded = "classic";

           

          Another thing you may want to do is to try assigning something certain to the textfield first, just to make sure it is being addressed properly... like have a button assign output.text = "testing";

          1 person found this helpful
          • 2. Re: Displaying a variable on stage problem
            rowancavanagh Level 1

            I've used the lead-in of _global now for them all, and then added this to one of the buttons, output.text = "testing"; which does work. It changes the text of the 'output' field.

             

            But still none of the changing values of _global.swfloaded work.

            • 3. Re: Displaying a variable on stage problem
              rowancavanagh Level 1

              I've used the lead-in of _global now for them all, and then added this to one of the buttons, output.text = "testing"; which does work. It changes the text of the 'output' field.

               

              But still none of the changing values of _global.swfloaded work.

               

              Cheers

               

               

               

               

              Date: Mon, 9 Nov 2009 13:28:58 -0700

              From: forums@adobe.com

              To: rowan.cavanagh@hotmail.com

              Subject: Displaying a variable on stage problem

               

              Whenever I used _global variables I found that continuing to use the lead-in of _global helped keep things working.  So in your case, where you say you used: swfloaded = "classic";,  I would have used: _global.swfloaded = "classic";

               

              Another thing you may want to do is to try assigning something certain to the textfield first, just to make sure it is being addressed properly... like have a button assign output.text = "testing";

              >

              • 4. Re: Displaying a variable on stage problem
                Ned Murphy Adobe Community Professional & MVP

                I think I may understand the problem.  I thought you meant you assign the output.text = swfloaded; each time a button gets clicked, but now I reread it and think that maybe you mean you assigned it once and expect that it will automatically adjust whenever the value changes.  If that is the case, that won't work.  Code only executes once when you enter a frame, unless it is called via some function on sone repeated basis.  You'll need to make it such that each time you change the value you update the output textfield by assigning it the value again.

                1 person found this helpful
                • 5. Re: Displaying a variable on stage problem
                  rowancavanagh Level 1

                  yes thats what I want. How would i do that then?

                   

                  without having to put the code in the same part as the buttons too

                  • 6. Re: Displaying a variable on stage problem
                    Ned Murphy Adobe Community Professional & MVP

                    You'll be eating up less processing time if you do use the buttons.  The only other way I can think of that you would not use the buttons would be to use an onEnterFrame routine to continuously update the textfield to the current value.

                    1 person found this helpful