1 Reply Latest reply on Apr 30, 2007 4:47 AM by dr_ross

    setting a variable from inside a function

    stuntounges
      I have a variable that i need to set from a function. The variable is located in the root of a movie clip.

      So I use:

      function myfunctinon() {
      _root.myvar = "myvalue";
      }

      Works great. The problem is that this movie can be loaded into other movies... so I don't know what the absolute path will be. All tutorials I see about this say to use _root. Any advice?


        • 1. Re: setting a variable from inside a function
          dr_ross Level 1
          Try to avoid the use of _root, like you say it inhibits future functionality. Try to target the correct scope of the variable by using the "this" and "_parent" properties.

          If you're really deperate you can user the _global prefix, but i'd advise against it.

          By keeping everything modularised internally and not using _root or _global you prevent overrighting other peoples code when working in teams, or leaving redundant code in memory when its long gone needed.