Flash Tips: The File Reference Class

{ December 23rd, 2007 }

Today is the second in a series of Flash tips, Thursaday I covered how to copy an array. Today’s tip is about the File Reference class.

When I was building the prototype for ConceptShare, I came across this class and was very excited to try it out as we needed a solution for uploading concepts directly from within the workspace. I went to google and began to search for examples of the code in action (my preferred method for discovering new techniques). I found two, both using basically the same code. I created my examples and started testing. Basic uploads worked like a charm, but when trying to integrate it into ConceptShare I was having no luck.

Hours of frustration later I figured out that when you call the upload function to send a file to the server, no cookies are transmitted along with the file. This was a problem because ConceptShare uses cookies for authenticating and identifying the user. In my case simply appending the required information as a querystring of the url and modifying the code to check the querystring instead of cookies for the necessary variables solved this problem.

Two things worth mentioning are:

AS 2.0 doesn’t allow for variables to be sent along with the file upload, but has since been added to AS 3.0.

FileReference.type property returns ‘.jpg’ on a Mac where as ‘jpg’ is returned on windows machines. This is because macs return a four-character file type.

If you enjoyed this post, make sure you subscribe to our web feed!

Categories: Development ~ ~ Trackback

Leave a Reply