开发者

How can I get plain text file in Flash?

Which function can I use to get the content of a plain text file?

I can just read "value=32" as a variable or file i开发者_Python百科n xml format now, but the file from vendor contains only the value "32".


Oops: Only now did I notice that you are on AS2: use LoadVars instead. (Got this from here)

var ldr = new LoadVars();
ldr.onData  = function (result:String) 
{
  if (success) 
  {
    trace("loaded " + result);
  }
  else
  {
    trace ("Error loading");
  }
} 
ldr.load("fileurl.txt");

The following applies only to AS3:

If the file is at your server (or a server that allows your swf to access it with a crossdomain.xml), you can load it using URLLoader.

var ldr:URLLoader = new URLLoader();
ldr.addEventListener(Event.COMPLETE, onLoad);
ldr.load(new URLRequest("fileurl.text"));

function onLoad(e:Event):void
{
  var loadedText:String = URLLoader(e.target).data;
  var value:Number = Number(loadedText);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜