Is that possible to fire Flash-button click-event via javascript ?
it`s my code , and i call fromJS() from javascript and it fires without any problem , but contain of this function :
myButton.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
does not work !
package
{
import flash.external.*;
import flash.net.FileReferenceList;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.system.Security;
public class MultiSelectClass extends MovieClip
{
private var fileRef:FileReferenceList;
function MultiSelectClass()
{
Security.allowDomain( "*" );
myButton.addEventListener(MouseEvent.CLICK, myButtonClick);
addCallbacks();
}
private function addCallbacks():void
{
if (ExternalInterface.available)
{
ExternalInterface.addCallback("sendToFlash", fromJS);
}
return;
}
function myButtonClick(ev:MouseEvent):void
{
fileRef = new FileReferenceList();
fileRef.browse();
}
private function fromJS():void
{
myButton.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
}
private function sendToJS():void
{
if (ExternalInterface.available)
{
ExternalInterface.call("alert","Hello as3");
}
}
}
}
You can do this using the ExternalInterface class and adding a callback handler to said function.
The flash side would look like this:
Then in your javascript, you just call that method from the flashObject.
Here is a link to official adobe documentation:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/external/ExternalInterface.html
-YOUR ISSUES IN THE COMMENTS-
Flash for security reasons will not let you popup the File browser without an actual mouse click, dispatching the mouse event manually does not fool it and there isn’t (or at least shouldn’t) be a workaround for this. The user will have to actually click your flash button to bring up the file browser (or to full screen a flash app).