您应该从服务器加载文件(使用URLLoader
类)然后您可以读取加载器的数据。
例如:
private var loader:URLLoader;
private function init():void {
loader=new URLLoader();
loader.addEventListener(Event.COMPLETE, dataLoaded);
loader.dataFormat=URLLoaderDataFormat.TEXT;
var req:URLRequest=new URLRequest("http://my-server/path/to/file");
loader.load(req);
}
private function dataLoaded(e:Event):void {
loader.removeEventListener(Event.COMPLETE, dataLoaded);
var data:String=loader.data;
//If the file is a flat text file (with 123.123.123.123:1234 on each line)
var lines:Array=data.split("\n");
for each(var line:String in lines) {
var i:Array=line.split(":");
trace("ip: " + i[0]);
trace("\nport: " + i[1]);
}
//If the file is an xml, do this
var x:XML=new XML(data);
for each(var host:XML in x.host) {
trace("ip: " + host.@ip);
trace("\nport: " + host.@port);
}
}
是的,您可以使用相对网址