我正在尝试使用 ExternalInterface 和 addCallback 从 javascript 执行 flex 函数:
<s:Application
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="initApp()">
import flash.external.*;
import flash.net.FileReference;
public function initApp():void {
ExternalInterface.addCallback("sendTextFromJS", receiveTextFromJS);
}
public function receiveTextFromJS(s:String):void {
l1.text = s;
var myFileReference:FileReference = new FileReference();
myFileReference.browse();
}
但由于某些原因,文件对话框未显示,但 ID 为 l1 的标签中的文本已更改。