14 Replies Latest reply on Apr 20, 2006 7:19 AM by injpix

    Can't load text in my movie

    Please_enter_a_nickn
      Hi,

      I'm having a hard time modifying a template I just bought.
      There's a Movie Clip I called foo_mc, and a dynamic text field in the MC that I called foo_txt
      Here's the Action Script I use, how come nothing's happening?
      the vars.txt file is in the same directory as the .FLA file and I save the file before testing it so that it doesn't search for the file in the temp directory
      The script below has been pasted in Frame 1 of a new layer I created in the main timeline.
      I'm using Flash 8.

      var loadit_lv:LoadVars = new LoadVars();
      loadit_lv.load("vars.txt");
      loadit_lv.onData = function(src:String) {
      if (src != undefined) {
      foo_mc.foo_txt.text = src;
      } else {
      trace("Could not load text file.");
      }
      };

      Thanks a lot, I'm pulling all my hair out.

      Ferris.
        • 1. Re: Can't load text in my movie
          injpix Level 3
          Have you embedded the font? You probably transformed the MovieClip somehow which would have prevented it from appearing on stage without embedding. You can click on the text field then go to the properties panel and embedded the font. I would select lines 2-5 for the glyphs in the “Character Embedding” menu.
          • 3. Re: Can't load text in my movie
            meme83
            This is an english forum so if you can ask a question in english you should be able to read the answer in english too? Anywho here's the translation of myIP's suggestion:

            [In English] Have you embedded the font? You probably transformed the MovieClip somehow which would have prevented it from appearing on stage without embedding. You can click on the text field then go to the properties panel and embedded the font. I would select lines 2-5 for the glyphs in the “Character Embedding” menu.

            [In Urdu] Tum nai font ko embed kiya flash main? Shayad tum nai apni MovieClip ko kisi terhan sai transform kar diya hai jis ke wajai sai wou flash kai stage par theek terhan sai nazar nahi aa rahi. Meri advice yeh hai kai tum apni 'text field' par click karo aur phir text field kai 'properties panel' main joa and aur 'embed' icon par click karo. Phir aik window pop-up hoge called 'Character Embedding', us main sai lines 2,3,4,5 select karo (u can click on cntrl on ur keyboard and then click on the lines 2-5 to select) and lastly click okay.

            hope that makes sense
            • 4. Can't load text in my movie
              Please_enter_a_nickn Level 1
              Hi myIP,

              Thanks for your help, although no joy
              I embedded the font and checked, lines 2-5 are now selected as you recommended.

              But in that dynamic text field, the same text always appears, the default one that's been set by the template author. I modified it to see if it would change once the movie was recompiled and it works, but I can't modify it dynamically.
              Any other idea?
              What can I put in my script to check if the problem is different than the file loading?
              For instance can I set the variable directly like:
              foo_mc.foo_txt.text = "test";
              I tried this and it doesn't change a thing, although I'm not sure the syntax is correct.

              Thanks,

              Ferris.
              • 6. Can't load text in my movie
                WebXperience Level 1
                What level are you loading the text info? Make sure that you have named the instance of your dynamic TextField and that you are loading the text file onto the same level as the movie the dynamic text is embeded in..
                • 7. Re: Can't load text in my movie
                  Please_enter_a_nickn Level 1
                  Cpt-K,

                  I'm not sure I'm wrong, can't we designate a nested object this way, isn't this the right syntax?
                  foo_mc.foo_txt.text = "test";

                  ----

                  WebXperience,

                  Thanks, I tried
                  foo_txt.text = "test";
                  on the foo_mc Movie Clip level and it worked.
                  But 2 questions remain:
                  Why can't I have the Action Script in the Main Timeline, using foo_mc.foo_txt.text = "test"; ?
                  I'm pretty sure I saw this type of syntax in the Macromedia documentation, but I can be mistaken.

                  And finally, foo_txt.text = "test"; works but this code doesn't... any ideas?

                  var features_lv:LoadVars = new LoadVars();
                  features_lv.onLoad = onText;
                  features_lv.load("vars.txt");
                  function onText(success:Boolean) {
                  if (success) {
                  foo_txt.text = features_lv.myvariablename;
                  } else {
                  trace("unable to load text file.");
                  }
                  }

                  Thanks again,

                  Ferris
                  • 8. Re: Can't load text in my movie
                    dswa45
                    Formatted text can dissapear sometimes. Have you checked http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_16054

                    The quick fix is to add a dummy textfield, with all the styles of the font (bold, italics) and perhaps also the same size and color as your dynamic textfield.
                    • 9. Re: Can't load text in my movie
                      injpix Level 3
                      Hmmm...this should really be an easy one. What dswa45 posted is interesting, although I don’t know if it still applies to Flash 8. You mentioned that this is a template. I am just curious if the author only embedded the font glyphs he or she needed at the time. So are you using the same font characters, font size and do you have all the settings as they were previously; bold, italic, leading and spacing?
                      • 10. Re: Can't load text in my movie
                        Please_enter_a_nickn Level 1
                        dswa45,

                        Actually the text appears, it's just that it's not the one I want, it's the default text.
                        Now that I did what WebXperience suggested, putting the Action Script in the Movie Clip timeline instead of the Main timeline, I can set the text manually, with foo_txt.text = "something";
                        I can't find a script that works to load variables from a text file thought, the samples given by Macromedia don't work in my case!

                        --------

                        myIP,

                        Actually there's a font missing, Flash asks me to substitute it when I open the FLA file, but it's not the font linked to the text I'm trying to change.

                        Thanks to both of you for your help.
                        • 11. Re: Can't load text in my movie
                          Please_enter_a_nickn Level 1
                          Okay, here's the core of my problem.
                          I took the sample script that's found in the Macromedia Help about loading text from files:

                          // Load text as variable and assign it to
                          // the dynamic text field
                          var features_lv:LoadVars = new LoadVars();
                          features_lv.onLoad = onText;
                          features_lv.load("safetyfeatures.txt");
                          function onText(success:Boolean) {
                          if (success) {
                          newFeatures_txt.text = features_lv.safetyfeatures;
                          } else {
                          newFeatures_txt.text = "unable to load text file.";
                          }
                          }

                          In the sample FLA that's in the Flash 8 package, if I change the name of the file to safetyfefatures.txt or whatever, I immediately get :

                          Error opening URL "file:///E|/Program%20Files/Macromedia/Flash%208/Samples%20and%20Tutorials/Tutorial%20Ass ets/Text/Add%20Text%20to%20a%20Document/safetyfefatures.txt"

                          But in the template I'm editing, if I add the exact same Action Script, I get no warning at all about the file not existing... and of course the variables in the file aren't read when I use the correct file name.
                          Does anyone know how this can be?

                          Many thanks.

                          Ferris.
                          • 12. Re: Can't load text in my movie
                            injpix Level 3
                            Did you purposely misspell “safetyfeatures.txt” to “safetyfefatures.txt" to prove your point? These errors are compile time errors correct? Is your problem solved?
                            • 13. Can't load text in my movie
                              Please_enter_a_nickn Level 1
                              Yes I purposely misspelled the file name to prove my point.

                              I don't understand why in the template I'm editing, it doesn't bother Flash that the file doesn't exist... with exactly the same code.

                              Thanks
                              • 14. Re: Can't load text in my movie
                                injpix Level 3
                                It was in your Publish Settings that made it not work as you desired. If you press in Flash;
                                CTRL+SHIFT+F12

                                …it will bring up your Flash settings. Although you did save the FLA to Flash 8 it doesn’t mean you changed the export settings. It was still compiling the SWF in ActionScript 1.0 in Flash Player 6. I changed it to ActionScript 2.0 and to Flash Player 8. You can set it to Flash Player 6 and it will work, but it will disable the character spacing! In order to activate that you need to change the player to a newer version. When doing this it will give you an error message if the file is not there. I don’t know why exactly, it may be because of the AS differences.
                                I hope this works out for you, I am lucky I noticed the PM. I usually never check it. Your thorough explanation of the problem in the PM also helped me out.