Yes, it's the same situation (in my case, I have a controller for image
management, and the entire process is done through events).
I solved it in FileBrowser.as (FileReference account) by adding a listener to
the "activeElement" click event and adding the selection dialog to the
activeElement's click event [1].
I'll test your code to verify that everything will still work if I push the
changes to the repository.
Thanks a lot for sharing.
[1] public function browse():void
{
COMPILE::SWF
{
delegate.browse();
}
COMPILE::JS
{
focusedButton = document.activeElement as
WrappedHTMLElement;
//trace("activeElement is: " + focusedButton);
focusedButton.addEventListener("blur",
blurHandler);
focusedButton.addEventListener("focus",
focusHandler);
window.addEventListener("keydown", keyHandler);
window.addEventListener("mousemove",
mouseHandler);
window.addEventListener("mousedown",
mouseHandler);
//delegate.click();
focusedButton.addEventListener("click",
clickHandler);
focusedButton.click();
focusedButton.removeEventListener("click",
clickHandler);
}
}
//New
COMPILE::JS
private function clickHandler(e:Object):void
{
delegate.click();
}
Hiedra
-----Mensaje original-----
De: [email protected] <[email protected]>
Enviado el: martes, 15 de abril de 2025 9:25
Para: [email protected]
Asunto: Re: mx.net.FileReference chrome
Hi Maria,
Perhaps it's the same issue I had with autoplay on videos. Some browser need a
user gesture event to enable it. Do you tried to add clic event to be sure that
the browse method is called in a user clic case ?
If it may help here is my working code :
<j:IconButton click="{ev_clic_choose_file(event)}" ...../> ....
public function ev_clic_choose_file2(e:MouseEvent):void {
var videosFilter:FileFilter = new FileFilter("Vidéo", "*.mp4;*.f4v");
_fr = new FileReferenceMulti();
_fr_index = 0;
_fr.browse([videosFilter]);
_fr.addEventListener(Event.COMPLETE, uploadCompleteHandler);
_fr.addEventListener(Event.SELECT, ev_SelectedFile); }
Le 2025-04-14 18:42, Maria Jose Esteve a écrit :
> Hi,
> I need your help because I'm stuck.
> In one of my applications, I use mx.net.FileReference to select a
> user's photo.
> It's always worked fine for me, but yesterday, while testing, I
> noticed that it stopped working in Chrome, although it still works as
> expected in Firefox.
> I'm not getting any errors, but I do see a warning in the debug
> console: "File chooser dialog can only be shown with a user
> activation."
> The traceback points to org.apache.royale.file.beads.FileBrowser in
> the
> browse() method:
>
> public function browse():void
> {
> COMPILE::SWF
> {
> delegate.browse();
> }
> COMPILE::JS
> {
> focusedButton = document.activeElement as WrappedHTMLElement;
> //trace("activeElement is: " + focusedButton);
> focusedButton.addEventListener("blur", blurHandler);
> focusedButton.addEventListener("focus", focusHandler);
> window.addEventListener("keydown", keyHandler);
> window.addEventListener("mousemove", mouseHandler);
> window.addEventListener("mousedown", mouseHandler); delegate.click();
> // <<<<<<<<<< -------------------------- Error } }
>
> I've verified that the delegate is still valid; it references the
> "input, type file" that's created.
> Any ideas on how to fix this?
>
> Thx.
> Hiedra