Browsers have certain security restrictions where you can't call certain APIs unless the user has interacted with the page in some way. In this case, if you want to call FileReference.browse(), it must be triggered by a listener for a user gesture, such as mouse click or key down.
-- Josh Tynjala Bowler Hat LLC https://bowlerhat.dev/ On Mon, Apr 14, 2025 at 9:42 AM Maria Jose Esteve <mjest...@iest.com> wrote: > 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 > >