views:

685

answers:

4

I want to open a file dialog via FileReference.browse() but I get #2176 error which means that this action can only be invoked upon some user interaction. I'm aware of security considerations but in my scenario I have a thin flash movie which merely displays an image and the whole UI is in javascript (I heavily use javascript <-> actionscript communication).

So the question is - do you think it would be possible to invoke FileReference.browse() upon the user interaction coming from javascript?

A: 

Isn't this the purpose of object and embed tags in html? When you say the whole UI is in javascript I am assuming you are using html markup as well, though I guess this may not necessarily be the case.

How to embed a flash file in html

How to start a flash file with javascript

Matthew Vines
I have no problem with referencing my flash movie from JS. I want to be able to call flash.net.FileReference.browse() on user interaction coming from JS (not AS).
Immortal
Apologies, I misunderstood your question. I'm afraid I'm not aware of a way to do what you are asking.
Matthew Vines
+1  A: 

No. If it is anything like accessing the clipboard, then you are stuck out of luck. I have tried all sorts of hacks to get around that, from setIntervals to using apply, I even tried using a ByteArray to manipulate code directly. No soap.

For that matter, you'll have to upload the file to a server using FileReference (unless you're using AIR). This is really annoying if you need to have Flash look at it.

The problem is that when Flash makes this type of decision, they are not making those aspects of the classes accessible by code directly. The code responsible for actually accomplishing these things is locked in the native code which is built into the FlashPlayer. We're black-boxed out.

Christopher W. Allen-Poole
+1  A: 

Back when Adobe first updated their security model, and in turn broke quite a few running flash based upload services, there was a

pretty

big

stink.

I believe that some people were working around the new limitation by essentially creating a transparent flash movie, and overlaying on top of an otherwise normal HTML element, to 'trick' the user into giving the flash app input from which to trigger the interaction (where they think they are clicking on a simple html button labeled 'upload' they are actually clicking on the invisible flash element sitting on top of it.)

I've not tried this method myself, but it may give you a direction in which to search for a solution that might work for you.

JStriedl
Thanks. I'll look into that - sounds promising.
Immortal
A: 

Ok. I've found this link: Flash Player 10 FileReference Changes. Apparently there's no workaround for this limitation. I guess I'll have to display a prompt for the user from within the flash movie, so that he/she can "interact" and allow to open the dialog.

Immortal