4 Replies Latest reply on Feb 7, 2007 6:14 AM by Designforce

    load array from text file

    lreadl
      When I use loadVars to load from a text file, I always get a string. Is there a way I can load data from the text file as an array? I ask because my text file is 17000+ words, and it takes 30 seconds to load it, and another 60 seconds to turn split it into an array. Loading it as an array would save a lot of time.
        • 1. Re: load array from text file
          kglad Adobe Community Professional & MVP
          no.
          • 2. Re: load array from text file
            Rothrock Level 5
            You could maybe try and XML file. It won't be an array exactly, but it might go smoother. (Or not.)
            • 3. Re: load array from text file
              kglad Adobe Community Professional & MVP
              it won't go smoother (or faster) with an xml file but you can use a preloader to display the load progress of it.
              • 4. Re: load array from text file
                Designforce
                I use this for arrays from external text files.

                Code:

                dataLVs = new LoadVars();
                dataLVs.load("data.txt");
                dataLVs.onLoad = function(success)
                {
                if (success)
                {
                trace("Input data = " + this.data);
                dataArray = this.data.split("|");
                trace("Output Data = ");
                for (i = 0 ; i < dataArray.length ; i++)
                trace(" dataArray[" + i + "] = " + dataArray );
                _mc1._display1.htmlText = dataArray[1];//loads immediately
                _mc2._display1.htmlText = dataArray[2];//loads immediately
                _mc3._display1.htmlText = dataArray[3];//loads immediately
                _mc4._display1.htmlText = dataArray[4];//loads immediately

                }
                }
                In this case I have a text file named data.txt which contains this:

                data=ACTIONSCRIPT IS VERY INTERESTING|DEVELOPMENT CAN BE QUICK|DEVELOPMENT CAN BE SLOW|DEVELOPMENT CAN BE DIFFICULT|DEVELOPMENT CAN BE FUN|GRAVITY|FLASHMX|CLICK|AUTHOR|BOUNCE|COFFEE|SUPER|BOOK|PAGES|GAME|OKAY|CODE|DX|EXPORT| COMPILE|CHARLESRIVER|GLENRHODES|WEB|MARSRACER|DIMENSION|MOVIECLIP|SCRIPT|TEXT&

                Hope this is what you were looking for.