Flash via tinkerproxy

I'm using tinkerproxy and trying to get flash to communicate with arduino. I downloaded the SerialPort.as Actionscript 3.0 class from the tinkerproxy web site (bottom of page @ http://code.google.com/p/tinkerit/wiki/TinkerProxy) and don't understand a certain bit of it (It's not really commented that well...).

So, 1. Could you guys please interpret this code for me? Or at least tell me what I would have to do to to get any data sent to flash from the arduino using this class? :

            private function onSocketData( event:ProgressEvent ):void
            {
                  dispatchEvent( new DataEvent( DataEvent.DATA, false, false, _socket.readUTFBytes( _socket.bytesAvailable ) ) );
            }

and 2. Maybe comment the whole thing and upload it here/ at the tinkerproxy site for future people to use?

Thanks!

I would also like to see how this is done. I have tinkerproxy working with a PHP telnet class.

Could you guys please interpret this code for me?

private function onSocketData( event:ProgressEvent ):void

This is declaring a function, onSocketData, that takes one argument, of type event, and returns nothing (void). Within the function, the input data is to be referred to as ProgressEvent.

The function contains just one instruction:

dispatchEvent( new DataEvent( DataEvent.DATA, false, false, _socket.readUTFBytes( _socket.bytesAvailable ) ) );

A new DataEvent object is created, and dispatched.

The DataEvent object takes 4 arguments. The final argument is the data of interest.

In this case, it is the data read from the serial port. _socket is the serial port. The bytesAvailable property defines how much data is available to read.

The readUTFBytes method() needs to be told how many bytes to read. It returns the data it read from the serial port as the data for the DataEvent object.

Somewhere, there needs to be defined a call to the onSocketData method, most likely as a callback for when serial data arrives on a specified port.

There also needs to be a callback registered to handle the DataEvent that is generated.

Without seeing more of the code, that is all I can tell you about this snippet.