是否有可能通過JavaScript觸發Flash按鈕點擊事件?與JavaScript的火Actionscript按鈕事件
它了我的代碼,我從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");
}
}
}
}
嘗試在myButtonClick函數中放置trace語句以確保它被調用。 – BadFeelingAboutThis 2012-08-03 18:01:41
或者,嘗試直接從'fromJS()'函數調用myButtonClick(null),並忘記分派點擊事件。 – BadFeelingAboutThis 2012-08-03 18:02:24
當您實際點擊閃光燈按鈕時它是否工作? – BadFeelingAboutThis 2012-08-03 18:30:59