开发者

Reading remote txt file with ActionScript

开发者 https://www.devze.com 2023-02-21 23:18 出处:网络
I\'m creating a banner for my website from Flash, and I\'m using Action Script to read information from a file to put开发者_JAVA百科 that info on the banner

I'm creating a banner for my website from Flash, and I'm using Action Script to read information from a file to put开发者_JAVA百科 that info on the banner

Now this seems to work fine for local files. But the file will not be on the same server as the script and banner.. (personal Reasons).

How can I read this remote text file? this text files location would be something like: http://www.some-server.com/text_file.txt this file is freely readable for anyone..


You shouldn't need any security sandbox exceptions or anything. Just use a URLLoader:

var myLoader:URLLoader = new URLLoader();
myLoader.addEventListener(Event.COMPLETE, onFileLoaded);
myLoader.load(new URLRequest("http://www.some-server.com/text_file.txt"));

private function onFileLoaded(e:Event):void
{
    var fileContents:String = String(e.currentTarget.data);
}
0

精彩评论

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

关注公众号