4 Replies Latest reply on Jun 16, 2006 4:42 AM by Rothrock

    Sum1 help before I kill LoadVars() !

    cosmicShame
      Hi, I am a programmer but new to flash. I made a script that reads data in from a text file and displays it in the flash.

      This works... kinda.

      The problem I am having is understanding the rules flash has for reading in data with LoadVars and actually having that data available. For some reason, the loading of the data always happens after my screen is drawn with my objects. When the flash initially loads the objects have 'undefined'. After the user generates a key press event, it works like a champ. I just have one frame in my movie that says something like

      var bla = new Bla();
      stop();

      I populate the public array that needs this data in the onLoad method, when I dump variables in debug, I can see the data had been read into memory. The problem is, it is not being read in first, even though I programed it to do so.

      I have a feeling this has something to do with the movieclip, but since I am mega newb, I have no idea and the flash docs say nothing about this.

      How to I get at this data ?
        • 1. Re: Sum1 help before I kill LoadVars() !
          cosmicShame Level 1
          Wow, sorry for dup threads, please respond to this one and discard the other.
          • 2. Re: Sum1 help before I kill LoadVars() !
            Rothrock Level 5
            var bla = new Bla();
            stop();

            hmmmm.... that is interesting. Where is the LoadVars()? If that is the part you are having trouble with, that would be the part to show us. My guess is that you expect flash to wait on the LoadVars() line until the content is loaded and then proceed. That is not how Flash works.

            It sends the load request and then keeps going merrily along. You need to wait until the data is fully loaded and then you can do something with it.

            Read the help files. Look in the ActionScript Dictionary or ActionScript 2.0 Language reference under the LoadVars class. You should see the onLoad() event and a code sample of how it works.

            Check the help files and post back with your code and we should be able to get this worked out for you.
            • 3. Sum1 help before I kill LoadVars() !
              cosmicShame Level 1
              Ya, but how do I know that it's done loading. You see the line:
              this.parentobj.addNew(this );

              The first time I run the flash this
              is undefined, then when I generate a key push event which I programed, the data flushes and there it is. What would be the proper way to put my data in my method so I have it in the begining ?

              addNew() basically pushes the data on to an array and redrawMenu() takes that array and draws what I want. Even though you can see I am redrawing my menu after I get my data it is not there.

              BTW I've prettly much memorized the LoadVars doc page.. lol Thanx for helping.

              Thanx.
              • 4. Re: Sum1 help before I kill LoadVars() !
                Rothrock Level 5
                The code is getting messed up with everything in italic. Makes me think there is a squarebracket-i someplace that I can't see. But regardless...

                I had missed that you were using the onLoad. So what is this parentobj? Just an object or is it an array? And the solution is probably in the "basically pushes the data on to an array."

                Over all it looks like it should work, but without knowing what addNew() and reloadMenu() do exactly it is hard to track down. Just work it through one step at a time to find which step is "loosing" the data.