4 Replies Latest reply on Jun 16, 2009 6:35 PM by EverLightMusic

    Preloading .txt content?


      I'm constructing a website in flash, and on each page of the website I have a dymanic text field pulling data from a .txt file for that page, (the news page has a dymanic text field called "newsText" which pulls data from "news.txt" for example)


      The website im working on is here:



      If you have a slower internet connection, whenever you click on the link to a new page, a small white square will appear in the corner before the content has fully loaded, this white square is a result of the scrollbar being disabled due to the content not being loaded yet (and thus having nothing to define wether or not it should need to scroll)


      as the website grows in content this will become more and more of a problem.


      My actionscript ability is really limited. So whats the simplest way I can add a preloader to the page to load the content of the .txt file before displaying it?


      Thanks guys!

        • 1. Re: Preloading .txt content?

          First make a text file called news.txt

          Then inside that put this




          Then on the parent time line of the text field put this code on the frame:



          loadVariablesNum ("news.txt", 0);





          • 2. Re: Preloading .txt content?
            EverLightMusic Level 1

            Well, I already have a news.txt file which has the content in it, so i assume i just add it to the begining of that?


            Also, I already have actionscript on the timeline for the dynamic text field which tells it to load the data, the code that is there looks like this:


            //init TextArea component
            newsText.html = true;
            newsText.wordWrap = true;
            newsText.multiline = true;
            //load in TXT
            newsContent = new XML();
            newsContent.ignoreWhite = true;
            newsContent.onLoad = function(success)
                            newsText.htmlText = newsContent;
            // Determine whether text box needs to scroll
            if (newsText.maxscroll > 1) {
            // display UIScrollbar component
            newsTextscroll._visible = true;
            } else {
            // hide UIScrollbar component
            newsTextscroll._visible = false;


            So if i do add that line of code, does it need to be added somewhere here?

            • 3. Re: Preloading .txt content?
              EverLightMusic Level 1

              I have found a small (and rather cheeky) work around for the time being until I can figure out a better solution.

              I have just simply put the word "Loading..." into the text box in flash, this then displays instead of the white box until the content is loaded, at which point it gets replaced.


              Its not the best thing, as a preloader which can load the txt files (and if possible, the images which are embedded using the <img> html tags within those text files), would be much smoother. But it'll hold until someone can help or I figure out a way by myself.

              • 4. Re: Preloading .txt content?
                EverLightMusic Level 1

                As you can see on the website I'm working on:


                I have a preloader at the start which loads the contents of the site, the actionscript for that preloader is as follows:


                // Initialize the preloading
                var pc = 0;
                this.onEnterFrame = function() {
                    pc = Math.floor((_root.getBytesLoaded()/_root.getBytesTotal())*100);
                    this.pc_txt.text = pc+"%";
                    this.bar._xscale = pc;
                    if (pc == 100 && !isNAN(pc)) {
                        delete this.onEnterFrame;


                Is there a way i can adapt this preloader to preload the contents of the .txt file?