3 Replies Latest reply on Dec 31, 2007 3:26 PM by kglad

    Turning external text file to a global?

    suntour16 Level 1
      Greetings and Happy New Year!

      I am having trouble passing a variable from an external text file to a global. I was hoping someone might show me where I went horribly wrong with this.

      The “trace(slide);” from within the function area seems to work fine but the other one doesn’t work “trace(number);”. All I get if the dreaded “undefined”.

      Any ideas?

      Thanks!
        • 1. Re: Turning external text file to a global?
          kglad Adobe Community Professional & MVP
          when you prefix a variable's definition with var (as in, var slide:String etc) inside a function body, that variable is local to the function and undefined outside the function (and even inside the function on subsequent function calls).

          to remedy, type your variable outside the function body and assign its value (without the var prefix) within the function body.
          • 2. Re: Turning external text file to a global?
            suntour16 Level 1
            Forgive me, but my knowledge of Action Script is fairly primitive.

            I understand what you’re describing about a variable being local to a function. I was starting to suspect that after trying different approaches to this on my own.

            However would you mind elaborating on how to just assign a value with out making it a var.? I always thought they were mutually exclusive.

            Are you suggesting something like “slide = this.total_number_of_slides;” If so how would one associate this with a Var.?

            Thanks again!
            • 3. Re: Turning external text file to a global?
              kglad Adobe Community Professional & MVP
              outside of class files, you don't even need to type your variables in as1/as2. so, you could use: