// uploader.fla // // Test. // // Copyright (C) 2006 Studio 4 // All rights reserved. // // This file contains proprietary and confidential information and remains // the property of Studio 4. Use, disclosure, or reproduction is // prohibited except by those permitted by explicit written license // agreement with Studio 4. // // Michiel Sikma import flash.net.FileReference; function fakeTrace(traceText:String):Void { fakeTracer.text += "\n"+traceText; }; function main():Void { // These are the colors used throughout the site. // Never hardcode a color value. _global.colorBlack = 0x000000; _global.colorWhite = 0xFFFFFF; _global.root = this; function renderInterface():Void { // Define the type of files that may be uploaded. var fileTypes:Array = new Array(); var imageTypes:Object = new Object(); imageTypes.description = "Images (*.jpg, *.jpeg, *.gif, *.png)"; imageTypes.extension = "*.jpg; *.jpeg; *.gif; *.png"; fileTypes.push(imageTypes); var listener:Object = new Object(); listener.onSelect = function(file:FileReference):Void { fakeTrace("Selected the file \""+file.name+"\"."); if (!file.upload(scriptLink.text)) { fakeTrace("Upload script (\""+scriptLink.text+"\") failed to open! Aborting."); } }; listener.onCancel = function(file:FileReference):Void { fakeTrace("Upload dialog was closed! Aborting."); }; listener.onOpen = function(file:FileReference):Void { fakeTrace("Opened the file \""+file.name+"\"."); }; listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void { fakeTrace("The file \""+file.name+"\" is being uploaded. Amount of bytes loaded: "+bytesLoaded+" of "+bytesTotal+"."); }; listener.onComplete = function(file:FileReference):Void { fakeTrace("The file \""+file.name+"\" has successfully been uploaded."); }; listener.onHTTPError = function(file:FileReference, httpError:Number):Void { fakeTrace("An onHTTPError exception has been thrown. File: \""+file.name+"\". HTTP error: "+httpError+"."); }; listener.onIOError = function(file:FileReference):Void { fakeTrace("An onIOError exception has been thrown. File: \""+file.name+"\"."); }; listener.onSecurityError = function(file:FileReference, errorString:String):Void { fakeTrace("An onSecurityError exception has been thrown. File: \""+file.name+"\". Error: \""+errorString+"\""); }; var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); uploadButton.onRelease = function():Void { fileRef.browse(fileTypes); }; }; renderInterface(); }; main();