我需要从服务器连续接收数据到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做这项工作?
自从我使用这个以来已经有一段时间了,但我认为XMLSocket可能是你想要的?它实际上不需要使用xml,我不认为,但可以只是一个套接字。
文档链接:http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00000442.html