LOADING
Loading
Hi , welcome back.
LogoutLOGOUT
 
  Lost password?  
Hi
 




 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 03-04-2006, 03:21 PM
DenkouNova's Avatar
DenkouNova DenkouNova is offline
Registered User
 
Join Date: Mar 2006
Location: Laval, Quebec, Canada
Posts: 21
Rep Power: 0
DenkouNova is on a distinguished road
Games Loading a text file: loading delay problems

I'm realizing I often have no idea how to work with the asynchronous environment of flash.

I'm trying to load a text file into a variable, with this simple method.

Actionscript:
public function loadPlainText(strPath:String):String {
  var myLoadVars:LoadVars = new LoadVars();
  var myText:String;

  myLoadVars.onData = function(src:String) {
	trace("src = " + src);
	myText = src;
  }
  
  myLoadVars.load(strPath);

  trace("myText = " + myText);

  return myText;
}

trace("LPT = " + loadPlainText("a.txt"));

Output goes
Code:
myText = undefined
LPT = undefined
src = *contents of the file*
how can I make sure the return statement is executed after onData?

Thanks a lot in advance

Last edited by FlashMove : 03-04-2006 at 03:43 PM
Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
XML Issue - Text Node Loading as "NULL" aura9 Flash MX ActionScript 10 04-29-2005 06:44 PM
External Text File String Into A Variable... Gramophone Flash MX 12 06-13-2004 03:38 AM
Movie clip needs to be controlled by parameters in text file tonyc Flash MX ActionScript 2 02-07-2003 11:36 AM
Sporadic loading of variables from a text file dogzi Server Side 3 11-29-2000 12:13 PM
loading variables from an external text file stereomike Flash 5 Actionscript 6 09-05-2000 09:34 PM




All times are GMT. The time now is 08:02 AM.