Skip to main content
Participating Frequently
June 16, 2009
Question

Preloading .txt content?

  • June 16, 2009
  • 1 reply
  • 500 views

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:

http://www.soundsculptmusic.com/

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!

This topic has been closed for replies.

1 reply

Known Participant
June 16, 2009

First make a text file called news.txt

Then inside that put this

newsText=yourtextgoeshere

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

loadVariablesNum ("news.txt", 0);

Cheers!

-javageek

Participating Frequently
June 16, 2009

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;
newsText.label.condenseWhite=true;
//load in TXT
newsContent = new XML();
newsContent.ignoreWhite = true;
newsContent.load("news.txt");
newsContent.onLoad = function(success)
{
        if(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?

Participating Frequently
June 17, 2009

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.