2 Replies Latest reply on Oct 4, 2006 5:23 PM by Robert Barr

    crazy question

    Robert Barr Level 1
      I realize that this might sound a bit crazy to ask, but since it was happening in my fla file, I figure I would try and find out why.
      It was my impression that once you marked a variable as being _global, you did not have to use the word _global anywhere else in the fla file in order toreference that variable. Am I wrong in this? I really shouldn't say that I am wrong in it since I had to mention the word _global in every part of the fla file that made use of that variable. I don't expect an answer to this actually, but I am just venting in a way.
        • 1. Re: crazy question
          2m Level 2
          As You can read in the help files:

          "A reference to the global object that holds the core ActionScript classes, such as String, Object, Math, and Array. For example, you could create a library that is exposed as a global ActionScript object, similar to the Math or Date object. Unlike Timeline-declared or locally declared variables and functions, global variables and functions are visible to every Timeline and scope in the SWF file, provided they are not obscured by identifiers with the same names in inner scopes.

          Note: When setting the value of a global variable, you must use the fully qualified name of the variable, e.g. _global.variableName. Failure to do so will create a local variable of the same name that obscures the global variable you are attempting to set."

          So: To set a global variable you have to declare it as _global. varName but you can retrive it without.
          • 2. Re: crazy question
            Robert Barr Level 1
            I guess that answers my question. I had a global variable set in frame 1 of the main timeline and set it to 0. I then wrote a function that used that variable, in the same frame and it had to be referenced by the term global becuase I was changing its value. Then in a movie clip, I was changing the value of the same variable in a button event. In each case I had to use the term _global.