1 Reply Latest reply on Feb 21, 2007 8:18 AM by Pop_Clingwrap

    Please help im dying!

    Darzna

      this problem is when i try to load a textfile w. variable
      first, when i clicked the button, and try to trace the loaded text, its shows its "undefined", but when i try clicking once more, it works... whats the problem? im really confused... please help! THANKS!

      PS:if you got a good tutorial about textfile and string manipulation, please send me some links... thanks!



      on (release) {



      var files

      loadText = new loadVars();

      loadText.onLoad = function(success) {
      if (success) {
      // trace(success);
      newsBox.html = true;
      newsBox.htmlText = this.myNews;
      }
      };
      loadText.load("test.txt");
      var snd = newsBox.getBytesTotal()




      var strt = Array ();

      strt= snd.split("#");

      trace(snd)
      gotoAndPlay(2);

      //split code: split str on delimeter into an 'array'


      //var strt:Array = snd.split("#");

      //trace(strt[0])

      }
        • 1. Re: Please help im dying!
          Pop_Clingwrap Level 1
          Not 100% sure this is the case but it may be because you are loading the file and running the trace at the same time so the text is not loaded when the trace is called. The second time you click the text is loaded from the previous call and so the trace works.

          Try stopping your playhead at frame 1 of your timeline untill the file is loaded then moving to frame 2 where your button appears. This way you can be sure that the vars are all available when the button is clicked.

          I would also recomend looking into using XML (if it fits your project) instead of text files as they tend to be a lot more dependable and more usable