« Announcing FotoBooth (web edition) | Main | SCOOP: Google has made a change to the way it indexes SWFs »
FileReference.browse() Bit Me on the Ass Today
| By Rich Tretola | October 17, 2008 | Print This Post
|
| 1,537 views |
Flash Player 10 changed the security settings on the FileReference.browse() method. I remember reading about that, and yet I let an app slip through without being updated and guess what happened?
Correct, when I expected the user to get the file dialog, the application just sat there.
So, for those of you who have no idea what I am talking about, Flash Player 10 put in some new security so that the only way to launch the file system dialog is though direct user interaction. In the application, I was referring to earlier, I was calling FileReference.browse() programatically within the result handler of a Cairngorm command. Don’t let this happen to you, check you code now.
Here is a very simple patch that I put in place that didn’t require reworking the entire application flow.
Wherever you have a FileReference.browse() that is being called programatically and is no longer working in Flash Player 10, simply create an Alert that allows allows the user to interact with the application which complies with the new security.
The sample code below shows a function called nonUserCalledFunction. This is the function that originally had the FileReference.browse() method being called programatically. In the new version, it throws an Alert to the user and then the event listener does the FileReference.browse() and everyone is happy again.
- import mx.controls.Alert;
- import mx.events.CloseEvent;
- private var fileRef:FileReference;
- private function nonUserCalledFunction():void{
- Alert.show("Allow ePage to access my file system","Permissions Required",Alert.OK|Alert.CANCEL,null,handleAlert);
- }
- private function handleAlert(evt:CloseEvent):void {
- if (evt.detail==Alert.OK) {
- fileRef = new FileReference()
- fileRef.browse();
- }
- }
I hope you didn’t experience this. If you did, I hope this helps solve your problem.
Topics: Flash Player, Flex, Flex 3 (Moxie) |








October 18th, 2008 at 11:41 am
I tried filererence.save() in flex3 using the latest build (no Gumbo), and got nothing no errors no nothing, will this work in flex 3?
Rich Tretola Reply:
October 18th, 2008 at 11:56 am
The error will only come into play if you call FileReference.save() programatically. If the user triggers the call though a button click, etc, there will be no problems.
November 3rd, 2008 at 9:52 pm
Another approach that did the trick for me… was using a hidden movie clip (button) and a wrapper method
ExternalInterface.addCallback(”browseWrapper”, null, browseWrapper); // called from my javascript file
function browseWrapper(){
browse_btn.onRelease();
}
function browse():Void{
fileRef.browse();
}
browse_btn.onRelease = browse;
Tim Reply:
November 3rd, 2008 at 10:10 pm
actually that didn’t work…. to many flash installs and uninstalls. Please Remove The Comment.
December 29th, 2008 at 2:44 pm
At 1:41pm on this cold December 29th, I sweat because both my Flu symptoms are peaking and my FB3 application has failed and I’m going into production on the 10 of January. I’ll return to this page to let you know if this actually works and will allow my application to pass the arguments into the headless .cfm cffile uploader. BRB with a tale of glory or defeat.