User Guide

404 Networking and Communication
{
var request:URLRequest = new URLRequest("http://www.[yourdomain].com/
fileUploadScript.cfm");
var file:FileReference;
var files:FileReferenceList = FileReferenceList(event.target);
var selectedFileArray:Array = files.fileList;
for (var i:uint = 0; i < selectedFileArray.length; i++)
{
file = FileReference(selectedFileArray[i]);
file.addEventListener(Event.COMPLETE, completeHandler);
try
{
file.upload(request);
}
catch (error:Error)
{
trace("Unable to upload files.");
}
}
}
function completeHandler(event:Event):void
{
trace("uploaded");
}
Because the Event.COMPLETE event is added to each individual FileReference object in the
array, Flash Player calls the
completeHandler() method when each individual file finishes
uploading.
Example: Building a Telnet client
The Telnet example demonstrates techniques for connecting with a remote server and
transmitting data using the Socket class. These techniques the example demonstrates are:
Creating a custom telnet client using the Socket class
Sending text to the remote server using a ByteArray object
Handling received data from a remote server