Flash AS3 Tutorials Center | Interesting Flash Animation Tutorials | Valuing Flash Animation Tutorials | Flash ActionScript and Animation Home

AS3 Beginner Tutorials | AS3 Basic Lessons | AS3 Valuing Courses | AS3 Components Tutorials | AS3 and PHP Interaction Tutorials
AS3 Practical Tutorials | AS3 Animation Techniques | AS3 Transition Effects Tutorials | AS3 Download Upload Files | AS3 Particle Systems
Communication Between Flash Movies with AS3 | AS3 and JavaScript interaction | AS3 Matrix Transformation | AS3 Physics Simulation Tutorials

Flash ActionScript Upload Files Procedures

As we mentioned before that the uploading files with Flash ActionScript 3 is actually Flash and PHP communication. The upload process is in fact handle by the PHP file. The role of Flash ActionScript is simply to pass the file information that need to be upload to web server to the PHP file.

The basic procedures of uploading file with Flash ActionScript are:

  1. Create a new instance of the FileReference class to work with.
  2. Create a new URLRequest instance sending data to the specified PHP file.
  3. Call the browse( ) method of the FileReference object to open a dialog box to browse user local disk for a file.
  4. Call the upload method with the URLRequest object as the parameter.
  5. PHP send confirmation back to Flash ActionScript when the uploading file is finished.

The Flash ActionScript upload file procedures can be illustrated with the following diagram:

flash actionscript 3 download file procedures

Flash ActionScript Codes:

//Create a new instance of the FileReference class to work with.
var myfileReference:FileReference = new FileReference();

 

// Create a new URLRequest instance sending data to the specified PHP file.

var myRequest:URLRequest = new URLRequest("upload.php");

 

// Call the browse( ) method of the FileReference object to open a dialog box

// to browse user local disk for a file.

myfileReference.browse();

 

// Call the upload method with the URLRequest object as the parameter.
myfileReference.upload(myRequest);

 

Remarks:

This Flash Actionscript 3 tutorial discuss how to use AS3 to upload file from user local computer drive to web server.