Bespoke App development for the Web and Devices

Accommodating the new reality for the FileReference class in existing projects


08.20.08 Posted in Actionscript by admin

This morning I read about the new rules regarding how to properly use FileReference.download() and FileReference.browse() in Flash Player 10 and quickly realised that this is going to impact one of my current projects.  Adobe has heightened security around how these are used.  Now they can only be called directly by a user interaction such as a button click.

I wasn’t too sure what the ramifications were going to be for my project so I decided to test it by viewing it in Internet Explorer with Flash Player 10 installed.  The project is a few years old and written in Actionscript 2 and I recently had to add save and load functionality to it (the budget didn’t stretch to a complete upgrade).

Here are my observations:

asfunction:
FileReference.download() and FileReference.browse() doesn’t seem to work when called using asfunction in a link defined within html text in a dynamic textfield.  I think this is just a bug in the pre-release player and I’ve filed a bug report here: https://bugs.adobe.com/jira/browse/FP-569.   This is not a problem when calling the same code from a movieclip’s ‘onRelease’ handler.  It is also worth noting that the equivalent feature in AS3 (TextEvent.LINK) does work with the FileReference class.

My save feature is broken:
My application’s save feature allows users to save the data that they have generated to their local machine.  It works by the user clicking the ‘save’ button, a server-side script then adds the data to a row in a database and returns a unique id for that row.  A custom event called ‘dataOnServer’ is triggered and this launches FileReference.browse() .  The browse dialog does not open in Flash Player 10 and I am interpreting this to be caused by the fact that I am indirectly calling FileReference.browse() as a result of a user interaction (instead of directly calling it).

The next course of action:

Well, I’ve already reported the asfunction/filereference bug but in the meantime I’ll have to use movieclip instances as buttons.

The broken save feature is going to have to be divided into a two-step process I think.  The first step will be to save the file on the server side and the second step will begin with a user interaction to save the file locally.  So far the best option that I’ve come up with is to save the file to the database when the user clicks the save button (as before).
However, this time an intermediary dialog pops up in the guise of a confirmation dialog (as in ‘are you sure you want to save this file?’).  This dialog is not selectable until the ‘dataOnServer’ event has been triggered.  Once selectable, the user can save the file locally by directly calling FileReference.browse() or choose not to.  This approach will hopefully mask a two-step process as a single operation.  Not as pretty as the original behaviour of the application but what are my options?

Any other suggestions are welcome

Update:

I’ve tested issue FP-569 (https://bugs.adobe.com/jira/browse/FP-569) on Player 10,0,12,36 on Firefox 3.0 and IE 6 and it appears to be resolved… great!

Post to Twitter



One Response to “Accommodating the new reality for the FileReference class in existing projects”

  1. "Bondage says:

    “bound gagged…

    Commercial BDSM; What Not to Learn from It:.”…

Leave a Reply

You must be logged in to post a comment.

Twitter Updates
Mobile site
QR Code - scan to visit our mobile site