是否可以通过 javascript 触发 Flash 按钮单击事件?
这是我的代码,我从 javascript 调用 fromJS() 并且它触发没有任何问题,但包含此函数:
myButton.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
不工作!
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");
}
}
}
}