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 Uploading File - Check if User Click on Save Button

This Flash ActionScript upload files process is similar to the downloading file. The Flash ActionScript need to know whether the user click on the Save button or Cancel button. In stead of clicking on the Save button, the user may choose click on the Cancel button not to upload the file.

Please update flash player to view this Flash ActionScript tutorial!

Flash Tutorial Content:

Same as the downloading files process, the Flash ActionScript will dispatch different events depending on which button has been clicked on:

  • The FileReference object will dispatch a SELECT event when the Save button has been clicked.
  • The FileReference object will dispatch a CANCEL event when the Cancel button has been clicked.
Therefore we can use the SELECT event and CANCEL event to add the Listener.

Flash ActionScript Codes:

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


// Listen to when Save button has been clicked on
myfileReference.addEventListener(Event.SELECT, fileSelected);


function fileSelected(evt:Event):void {

output_txt.text = "File selected upload: " + evt.target.name;


function browseFile (event:MouseEvent):void {

// Use browse( ) method of a FileReference object to open a
// dialog box to browse local disks for a file.


// Hook up the button with the function browseFile
browse_btn.addEventListener(MouseEvent.CLICK, browseFile);

Download Flash Source File:

Flash Source File as3-upload-file-02.fla


To simplify the Flash ActionScript codes, the CANCEL event to add the Listener is not included in this tutorial shows. Please check the Flash ActionScript downloding file tutorial.