9 Replies Latest reply on Aug 6, 2006 9:53 PM by Captain Pill

    LoadVars Help needed.

    GrannyMaude


      Hi,
      I'm creating a LoadVars object in my main movie thusly:

      //------------- Loadvars Object ---------------//
      var myLV:LoadVars = new LoadVars();

      myLV.onLoad = function (success:Boolean) {
      if (success) {
      _level5.loadedInfo.htmlText = myLV.info;
      } else {
      _level5.loadedInfo.text = "There has been an error loading the requested information. Please contact the webmaster and report your error."
      }
      }
      //------------- Loadvars Object ---------------

      _level0.myLV.load("grannytext.txt")


      When I test my movie, nothing is getting loaded into loadedInfo, which is the instance name of a dynamic text box I have on the stage. I've tried everything that I can think of to get it to load including changing "_level0" to "this" and,, "_parent" to no avail. I have also made triple and quadriple sure that my spelling of the filename I want to load are correct, as well as the instance names.

      Any help would be much appreciated. BTW, I'm using Flash 8 Pro.

      Thanks.
        • 1. Re: LoadVars Help needed.
          zensoldier
          myLV["info"]

          if grannyText.txt is returning

          &info=the string you want
          • 2. Re: LoadVars Help needed.
            GrannyMaude Level 1
            quote:

            Originally posted by: zensoldier
            myLV["info"]

            if grannyText.txt is returning

            &info=the string you want


            I don't understand. If I use myLV("info") (which is the label name I've put into the text file, thusly: info=lotsoftextafterthis), how does LoadVars know the name of the file to get the 'info' from? This doesn't make any sense to me.
            • 3. Re: LoadVars Help needed.
              Rothrock Level 5
              First thing I would remove the _level0 from

              myLV.load("grannytext.txt");

              I don't think it is causing any problems, but it looks strange to me. Unless the code that is doing the load is actually on a different timeline or level than where the LoadVars is defined then you don't need it. If it is on a different timeline or level you haven't mentioned the added complexity of your file.

              The next step is that there are several places where this could be going wrong. The text file might not be loading or once it is loaded maybe the problem is assigning the text.

              Probably the easiest thing would be to go to the debug menu in the testing environment and do a list variables. If needed, add a stop() to that frame to stay there so you can see what variables are in play on that frame.

              You should see that the LoadVars is defined and has data in it.

              It should also give you the exact path to the loadedInfo text field.

              Of course one last thought is that you don't have html property set for true on your text field. What happens if the granny text file isn't there? I noticed that your error message you use text, but on the info you used htmlText.
              • 4. Re: LoadVars Help needed.
                GrannyMaude Level 1
                quote:

                Originally posted by: Rothrock
                First thing I would remove the _level0 from

                myLV.load("grannytext.txt");

                Of course one last thought is that you don't have html property set for true on your text field. What happens if the granny text file isn't there? I noticed that your error message you use text, but on the info you used htmlText.


                The reason that the error trap doesn't have the .htmlText property set is because I quote the message in plain text, though I suppose I could format it a little and set the property to the .htmlText just to be more consistent.

                Thanks for the tips. I'll do what you suggested and see if I can come up with anything.


                • 5. Re: LoadVars Help needed.
                  GrannyMaude Level 1
                  Ok, I tried your suggestions and even put some trace statements into the code to see 'success' was evaluating to true or false and it is coming back as being true, which means that myLV has loaded the contents of the file into LoadVars. The only thing is, that it's still not displaying in the instance of the dynamic text field at runtime. UGH! I'm about to pull my hair out over this one.

                  Any thoughts?
                  • 6. Re: LoadVars Help needed.
                    Rothrock Level 5
                    So when you did the Debug–>List Variables did you see where exactly the dynamic text field is defined? Make sure that is the same as what you have in your code.

                    Also test to make sure the variable info is in your LoadVars. Put this inside of your successful block in the onLoad:

                    trace("The info is: "+this.info);

                    Finally if that works, and your path is the same as what you see in the list variables then the only thing I can think of is that the dynamic text field doesn't actually exist at the time the onLoad is getting called?

                    One other thing could be that you have embedded some characters for that text field, but not the correct characters to show the text you want.

                    I can also think of one other thing to try. And that would be to put some other "default" text into the dynamic field and see if that gets changed.
                    • 7. Re: LoadVars Help needed.
                      GrannyMaude Level 1
                      Rothrock,
                      I put the trace statement in there and sure enough, the text from the file that is being loaded into the LoadVars variable is being displayed in my output box, and success, as before, is being correctly evaluated as true. But, it's still not being displayed in the dynamic text field.

                      I also tried putting some dummy text into the text field to see if it displayed at runtime and sure enough, it is. So what does that tell me? The LoadVars variable myLV is being loaded with the contents of my text file correctly, but it's not being loaded into the text field at runtime.

                      I'm really stumped on this one.

                      Perhaps I should just start over and ask, "How do you load the contents of an external text field into a dynamic text box?" Any code samples would be HIGHLY appreciated.

                      Thanks.
                      • 8. Re: LoadVars Help needed.
                        Rothrock Level 5
                        You seem to be doing everything correctly. So the only thing I can think of is that it is a timing issue. Are you certain that the text field exists at the time the onLoad is getting called?

                        Keep the default text in you text field. And add this to your success block (I'm not exactly sure of the path so make it match you actual setup:

                        trace("The default text is: "+_level5.loadedInfo.text);

                        What happens now? Do you see the dummy text you put in the field?
                        • 9. Re: LoadVars Help needed.
                          Captain Pill
                          in your .txt u have to put "info=the reste of the test" so u declare your variable.
                          u doing linda.com tutorial...lol