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);
Summary of Contents for FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Page 1: ...Learning ActionScript 2 0 in Flash...
Page 8: ...8 Contents...
Page 18: ...18 Introduction...
Page 30: ...30 What s New in Flash 8 ActionScript...
Page 66: ...66 Writing and Editing ActionScript 2 0...
Page 328: ...328 Interfaces...
Page 350: ...350 Handling Events...
Page 590: ...590 Creating Interaction with ActionScript...
Page 710: ...710 Understanding Security...
Page 730: ...730 Debugging Applications...
Page 780: ...780 Deprecated Flash 4 operators...
Page 830: ...830 Index...