Use the Socket ActionScript class. Take a picture of the scene (using the BitmapData class) and send it to another script running on your computer through the socket, where the image is saved. I should have used Python like this, and it worked perfectly. For animation, you may not get the best frame rate. But that should be fine, as long as the animation is time-independent.
An example of how you do this (untested):
var sock:Socket = new Socket(yourIP, somePort); var drawRect:Rectangle = new Rectangle(0, 0, 550, 400); var bmp:BitmapData = new BitmapData(drawRect.width, drawRect.height, true, 0x00000000); bmp.draw(stage, null, null, null, drawRect); var pixels:ByteArray = bmp.getPixels(drawRect); for each (var pixel in pixels) { sock.writeUnsignedInt(pixel); }
Note that you may need to put the last fragment in the "connect" event. And also note that I'm still migrating to AS3, so some of them might be deprecated.
source share