我需要从服务器到Flash客户端不断接收数据,并且可以在as3中使用以下代码:
public class ASHXTest extends Sprite
{
public function ASHXTest()
{
this.init();
}
private var urlStream:URLStream;
private var outField:TextField;
private function init():void
{
var req:URLRequest = new URLRequest("http://5.9.121.41/Handler.ashx");
urlStream = new URLStream ;
urlStream.addEventListener(ProgressEvent.PROGRESS,onStreamProgress);
urlStream.addEventListener(SecurityErrorEvent.SECURITY_ERROR,onError);
urlStream.addEventListener(IOErrorEvent.IO_ERROR,onError);
urlStream.load(req);
outField = new TextField ;
outField.autoSize = "left";
this.addChild(outField);
}
protected function onError(event:Event):void
{
outField.text = event.toString();
}
protected function onStreamProgress(event:ProgressEvent):void
{
var data:String = urlStream.readUTFBytes(urlStream.bytesAvailable);
outField.appendText(data + "\n");
}
}
不幸的是我的项目用as2编写,是否可以在flash as2中完成这项工作?
答案 0 :(得分:0)
我使用它已经有一段时间了,但我认为XMLSocket可能是你想要的?它实际上并不需要使用我不认为的xml,但可以只是一个套接字。
文档链接:http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00000442.html