Flash – File IO
Feb 7, 2007 Uncategorized
Ain’t they just the greatest?
I’ve got tons to prepare for the start of school, and lots of backlog to clear before I leave too. So I’ll be doing just that. However, that doesn’t mean I will be neglecting what I prefer to be doing, which is, thinking of horrendously complicated solutions to simple problems. In this case, it’s a little project I’m working on, experimenting a little with file operations in Flash. This is where FileReference comes into the picture.
Using the FileReference class is a Class A Pain in the Booty. It took me awhile to get to grips with it, and discover the full range of limitations that accompany this security-savvy package. So that is the first topic of today:
Understanding the FileReference Class – According to Me
The two most important methods of the FileReference Class is upload(); and download();. These methods are the main movers of files in Flash. This, of course, raises a couple of questions. Isn’t a FileReference Class supposed to be for File References?
Of course, in the perfect world, I’m sure things wouldn’t be this way. But in this day and age of cyber maliciousness, security is an issue. What we got here, instead, is a dumbed-down package with limited capabilities. It’ll let you upload a file you pick, and also lets you choose a location to download a file. At no time will you be able to know which file it is exactly, nor will it give you any information about directory trees.
Uploading also sounds really complicated. Some people might get put off by having to code their own scripts for handling such operations. Having some server-scripting experience would come in handy right about now. Lets also not forget the mandatory browse(); method, which you must call before calling upload();.
Downloading isn’t as complicated, unless you want it to be. (Remember what I said about horrendously complicated solutions to simple problems?) Downloading a file can be as simple as passing a URL to a file, or as versatile as using a server script to deliver your content to you. Calling the browse(); method is not required, since download(); will provide a dialog box for you anyway.
What is the easiest way to understand these methods? Think of them as forms (you know, those upload forms which you use to put pictures of your cat on Flickr for nobody to see). In Flash, you don’t have to build the form necessarily, but the backend remains the same. Thinking of it in those terms will ease your mind a little. So, finding a tutorial on how to code a script to handle FileReference uploads is the same as tutorials on uploading scripts.
Simple yes?
Oh don’t forget that FileReference’s Field Name defaults to “filedata”, unless you want to change that. (What? You didn’t think it was THAT simple, did you?)
Tags: Rants






Leave a Reply