EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Page 648

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
648 Working with External Data
import flash.net.FileReference;
imagePane.setSize(400, 350);
imagePane.move(75, 25);
uploadBtn.move(75, 390);
uploadBtn.label = "Upload Image";
imageLbl.move(75, 430);
imageLbl.text = "Select Image";
statusLbl.move(210, 390);
statusLbl.text = "Status";
imagesCb.move(75, 450);
statusArea.setSize(250, 100);
statusArea.move(210, 410);
/* The listener object listens for FileReference events. */
var listener:Object = new Object();
/* When the user selects a file, the onSelect() method is called, and
passed a reference to the FileReference object. */
listener.onSelect = function(selectedFile:FileReference):Void {
/* Update the TextArea to notify the user that Flash is attempting to
upload the image. */
statusArea.text += "Attempting to upload " + selectedFile.name + "\n";
/* Upload the file to the PHP script on the server. */
selectedFile.upload("http://www.helpexamples.com/flash/file_io/
uploadFile.php");
};
/* When the file begins to upload, the onOpen() method is called, so
notify the user that the file is starting to upload. */
listener.onOpen = function(selectedFile:FileReference):Void {
statusArea.text += "Opening " + selectedFile.name + "\n";
};
/* When the file has uploaded, the onComplete() method is called. */
listener.onComplete = function(selectedFile:FileReference):Void {
/* Notify the user that Flash is starting to download the image. */
statusArea.text += "Downloading " + selectedFile.name + " to
player\n";
/* Add the image to the ComboBox component. */
imagesCb.addItem(selectedFile.name);
/* Set the selected index of the ComboBox to that of the most recently
added image. */
imagesCb.selectedIndex = imagesCb.length - 1;
/* Call the custom downloadImage() function. */
downloadImage();
};
var imageFile:FileReference = new FileReference();
imageFile.addListener(listener);

Table of Contents

Related product manuals