I don't know much about MATLAB and how to program for it but I'll give you an example on the AS3 side. If you want to use the TCP/IP communication first of all you'll need to define a server and a client. ServerSocket class is only supported for AIR applicaitons on the Flash side so you should decide whether to make Flash side server or client. In case you want it to be server you'll need to write something like this:
const IP_ADDRESS:String = "127.0.0.1"; //for local hosting
const PORT:uint = 3444; //basically, you can take any port you want, but higher would be better so that it won't have issues with other programs using ports.
var OurServerSocket:ServerSocket = new ServerSocket();
var ConnectedSocket:Socket;
OurServerSocket.addEventListener(ServerSocketConnectEvent.CONNECT, HandleSocketConnection); //adding listener for socket connections, that we'll handle in our method.
OurServerSocket.bind(PORT, IP_ADRESS); //just binding our socket to the IP and port that we defined
OurServerSocket.listen();
function HandleSocketConnection(e:ServerSocketConnectEvent):void
{
ConnectedSocket = e.socket; //just saving connected socket instance
ConnectedSocket.addEventListener(ProgressEvent.SOCKET_DATA, HandleSocketData); //adding listener to handle any data that comes through our connected socket
trace("Connected: " + ConnectedSocket.remoteAddress);
}
function HandleSocketData(e:ProgressEvent):void
{
var socket:Socket = e.target as Socket;
var bytes:ByteArray = new ByteArray();
socket.readBytes(bytes,0,0);
var Data:String = bytes.toString(); //when the data comes in we store it in this string so that you can than manipulate easily
}
//use this function to send data through the connected socket
function WriteToSocket(data:String):void
{
var dataArray:ByteArray = new ByteArray();
dataArray.writeMultiByte(data, "utf-8");
ConnectedSocket.writeBytes(dataArray);
}
If you'll decide client for the Flash side connect to your server like this:
var SocketConnection:Socket = new Socket();
SocketConnection.connect(IP_ADDRESS, PORT);
Then you can communicate using the same methods for writing and reading.