views:

420

answers:

3

I am very interested in streaming data for web-applications. I have tried out some javascript libraries, but the hacks and browser-incompatibilities drive 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 functionality that Flash offers.

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

+3  A: 

Though I'm not familiar with what you're doing, it sounds like you should be looking at URLStream. When you're loading things that Flash intuitively understands (MP3s, JPGs, SWFs and so on) then you would normally use a Loader, and then too you can get progress events, but I'm guessing you're talking about loading arbitrary data into a ByteArray, and URLStream should give you all the low-level access you need.

That's assuming you're using AS3, and Flash Player 9+. I wouldn't swear to it, but I'm pretty sure what you're looking for is not possible under AS2.

fenomas
Thanks, URLStream seems to be exactly what I was looking for.
I.devries
+2  A: 

If you're just looking to stream a single file, use URLStream, as fenomas suggested. If you want an open connection that can both send and receive data, the class you're looking for is XMLSocket. Should work on anything past Flash 5.

Moss Collum
A: 

As Moss Collum and fenomas have suggested, there's URLStream and XMLSocket. But if you want to interact with a server on a binary level, you can read and write bytes with a Socket object.

Bear in mind that any network communication is subject to Flash Player's very rigid Security Model. You may find that learning about this will be time very well spent.

aaaidan