Skip to main content
Participant
September 1, 2013
Answered

Preload Text from an External Site

  • September 1, 2013
  • 1 reply
  • 417 views

I am using this actionscript multiple times within a document:

var loader1:URLLoader = new URLLoader(new URLRequest("http://www.url.com/example.txt"));

loader1.addEventListener(Event.COMPLETE, completeHandler);

function completeHandler(event:Event):void {

var loadedText1:URLLoader = URLLoader(event.target);

Box.text = loadedText1.data;

}

Unfortunately, there tends to be a significant lag in terms of this text appearing. How can I get flash to cache these text files before it called upon to display them? -- kinda like a pre loader for text files.

This topic has been closed for replies.
Correct answer Ned Murphy

The time it takes to download the file is the time it takes, and the code you show is dealing with it as soon as it has been downloaded.  To cache it before it is called upon to display them you need to do everything but that last line of code ahead of time.  Load the data and store it somewhere so that you can assign it when it needs to be assigned.

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
September 1, 2013

The time it takes to download the file is the time it takes, and the code you show is dealing with it as soon as it has been downloaded.  To cache it before it is called upon to display them you need to do everything but that last line of code ahead of time.  Load the data and store it somewhere so that you can assign it when it needs to be assigned.