Following the example that builds the Flash application is an example that details the server-
side code. Remember that image files are restricted in size: you can only upload images that
are 200K or smaller.
To build a FLA application using the FileReference API:
1.
Create a new Flash document and save it as fileref.fla.
2.
Open the Components panel, and then drag a ScrollPane component onto the Stage and
give it an instance name of imagePane. (The ScrollPane instance is sized and repositioned
using ActionScript in a later step.)
3.
Drag a Button component onto the Stage and give it an instance name of uploadBtn.
4.
Drag two Label components onto the Stage and give them instance names of imageLbl and
statusLbl.
5.
Drag a ComboBox component onto the Stage and give it an instance name of imagesCb.
6.
Drag a TextArea component onto the Stage and give it an instance name of statusArea.
7.
Create a new movie clip symbol on the Stage, and open the symbol for editing (double-
click the instance to open it in symbol-editing mode).
8.
Create a new static text field inside the movie clip, and then add the following text:
The file that you have tried to download is not on the server.
In the final application, this warning might appear for one of the following reasons,
among others:
The image was deleted from the queue on the server as other images were uploaded.
The server did not copy the image because the file size exceeded 200K.
The type of file was not a valid JPEG, GIF, or PNG file.
The width of the text field should be less than the width of the ScrollPane
instance (400 pixels); otherwise users have to scroll horizontally to view the
error message
9.
Right-click the symbol in the Library and select Linkage from the context menu.
10.
Select the Export for ActionScript and Export in First Frame check boxes, and type
Message into the Identifier text box. Click OK.
11.
Add the following ActionScript to Frame 1 of the Timeline:
The code comments include details about the functionality. A code overview follows
this example.
About file uploading and downloading
647
Need help?
Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?