0

i need to receive data continuously from server to flash client and it is possible in as3 with this code :

    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");
        }
    }

Unfortunately my project written in as2 , is it possible in flash as2 to do this job?

Amin Gholibeigian
  • 1,325
  • 2
  • 9
  • 11

1 Answers1

0

It's been a little while since I have used this, but I think XMLSocket may be what you want? It doesn't actually need to use xml I don't think, but can be just a socket.

Link to documentation: http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00000442.html

mitim
  • 3,169
  • 5
  • 21
  • 25
  • i don't want to use sockets – Amin Gholibeigian Mar 17 '13 at 08:38
  • Hrm, Someone else may know, but I am not so sure there is another way within AS2 then. The entire point of a socket is to maintain a connection to a server so that data can be exchanged back and forth continuously as soon as the data is available. Else you need to wait for http requests (as mentioned in the doc link). – mitim Mar 17 '13 at 08:55
  • I am looking for a kind of stream downloading the data – Amin Gholibeigian Mar 17 '13 at 11:51