3 Replies Latest reply on Oct 1, 2006 2:58 PM by kglad

    loadVars variable not accessible

    calmchess333 Level 1
      /*
      goal get the username2 variable inside the myLoadvars.onLoad = function
      to be accessible from outside its function.

      I've been told that adding a key frame to the timeline will allow the username2
      variable to be used outside its function, which works but this script is
      part of a larger script and the keyframe causes a movie clip on stage to blink
      and display wrong.

      I've attempted to use stops(); and gotoAndPlay(); to control the frames/blinking
      but that either stops the loadVars script or causes the movie clip to blink faster.

      I've also attempted to put the movieclip on keyframe 6 then used
      gotoAndPlay(6) stop(); on key frame 5.
      Which stops the movieclip from blinking but as you know the script on frame 1
      isn't accessible from frame 6 because of the stop(); on frame 5.

      How can i access the username2 variable?
      */

        • 1. Re: loadVars variable not accessible
          kglad Adobe Community Professional & MVP
          that's a timing issue . your code below your onLoad() handler executes before your onLoad() handler is called and therefore before myLoadVars.valid is defined.

          also, you're likely to cause problems using _root.username2 and having a myLoadVars.username2.
          • 2. Re: loadVars variable not accessible
            calmchess333 Level 1
            i've come to the same conclusions except that still doesn't work
            nor explain how to write the code so that I can use the data loaded
            from the loadVars object from anywhere within the script except from within
            the function.
            • 3. Re: loadVars variable not accessible
              kglad Adobe Community Professional & MVP
              what username2 variable do you want to access? myLoadVars.username2 or myLoadVars.valid? both those references will work if used AFTER they're defined. ie, after your onLoad() handler executes.

              whether you use that code inside or outside of your onLoad() handler is irrelevent: both will work. it's the timing that's important and causing you problems. (in addition, you may confused be confused about the two different username2 variables you defined in your first post.)