如何从javascript启动Flash视频?

Geo*_*Geo 1 javascript flash playback

是否可以通过使用JavaScript代码开始在Flash播放器中播放文件?如果是这样,我该怎么做?

tot*_*ter 6

尝试使用swfObject,您可以使用javascript显示任何actionscript函数ExternalInterface并将其声明为javascript.因此,您可以使用play()javascript代码触发actionscript函数(或任何其他您想要的代码).

这是一个例子:

动作:

import flash.external.ExternalInterface;

ExternalInterface.addCallback( "methodName", this, method );
function method() {
   trace("called from javascript");
}
Run Code Online (Sandbox Code Playgroud)

使用Javascript:

function callAS() {
   swf.methodName(); 
}
Run Code Online (Sandbox Code Playgroud)

其中methodName是js用于从actionscript调用方法的标识符.