(How) Can you implement street HTTP (comet / long lived connections) in Flash?

I am very interested in streaming data for web applications. I've tried some javascript libraries, but the hacks and browser incompatibilities are driving me crazy! HTML5 will hopefully standardize streaming data, but until then, hopefully I can resort to Flash to make this work in all browsers. Unfortunately, I'm not very familiar with all the features that Flash offers.

I tried loadVariables.onData in Flash 8, but it doesn't support streaming data. The data is available only after the request is completed. Is there a way to call the function every time new data is returned?

+1


source to share


3 answers


While I'm not familiar with what you are doing, it looks like you should be looking at the URLStream . When you load things that Flash intuitively understands (MP3, JPG, SWF, etc.), you usually use a Loader and then you can get progress events as well , but I assume you are talking about loading arbitrary data into a ByteArray. and the URLStream should give you low-level access you want.



Let's assume you are using AS3 and Flash Player 9+. I wouldn't swear to it, but I'm pretty sure what you are looking for is not possible in AS2.

+3


source


If you're just trying to stream a single file, use a URLStream as the phenom implies. If you want to open a connection that can send and receive data, the class you are looking for is XMLSocket . Should work on anything that was in Flash 5.



+2


source


As Moss Collum and the Phenomes suggested, there URLStream

and XMLSocket

. But if you want to interact with the server at a binary level, you can read and write bytes with the object Socket

.

Remember that any network communication is subject to the very tight Flash Player security model. You may find that learning this can be very time consuming.

0


source







All Articles