I'm using Flash to play an .flv movieclip on my site, but I want to have the .swf send trigger an event in my javascript when it start loading, starts playing and ends playing.
我正在使用Flash在我的网站上播放.flv动画片段,但我希望在开始加载,开始播放和结束播放时,我的javascript中的.swf发送触发事件。
What is the best way to do that in Flash CS3 using Actionscript 3.0 ?
使用Actionscript 3.0在Flash CS3中执行此操作的最佳方法是什么?
3 个解决方案
#1
5
You need to use the "allowScriptAccess" flash variable in the HTML. You probably want to use "sameDomain" as the type. Note that if you go cross-domain, you also need to host a special file on the server called 'crossdomain.xml' which enables such scripting (the flash player will check for this. More info at http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_14213&sliceId=2
您需要在HTML中使用“allowScriptAccess”flash变量。您可能希望使用“sameDomain”作为类型。请注意,如果您进入跨域,则还需要在服务器上托管一个名为“crossdomain.xml”的特殊文件,该文件启用此类脚本(Flash播放器将检查此内容。更多信息,请访问http://kb.adobe。 COM /自助服务/ viewContent.do?外部ID = tn_14213&sliceId = 2
The call is the easy part. :-) In the Flash code, you'll use the ExternalInterface to do the call, as documented here:
电话很容易。 :-)在Flash代码中,您将使用ExternalInterface进行调用,如下所示:
Short version: you say
简短版:你说
ExternalInterface.call("javascriptFunction", "argument")
#2
4
A common way to do this is with the ExternalInterface class, which you can use to call JavaScript methods.
执行此操作的常用方法是使用ExternalInterface类,您可以使用它来调用JavaScript方法。
First define your JavaScript methods, for example:
首先定义您的JavaScript方法,例如:
<script language="JavaScript">
function startsPlaying()
{
// do something when the FLV starts playing
}
</script>
Then modify your ActionScript to call the JavaScript method at the appropriate time:
然后修改ActionScript以在适当的时候调用JavaScript方法:
// inform JavaScript that the FLV has started playing
ExternalInterface.call("startsPlaying");
For more information, see the related Flash CS3 documentation.
有关更多信息,请参阅相关的Flash CS3文档。
#3
2
if you don't want to load
如果你不想加载
import flash.external.*;
so you can also do a
所以你也可以做一个
getUrl("javascript:startsPlaying();");
#1
5
You need to use the "allowScriptAccess" flash variable in the HTML. You probably want to use "sameDomain" as the type. Note that if you go cross-domain, you also need to host a special file on the server called 'crossdomain.xml' which enables such scripting (the flash player will check for this. More info at http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_14213&sliceId=2
您需要在HTML中使用“allowScriptAccess”flash变量。您可能希望使用“sameDomain”作为类型。请注意,如果您进入跨域,则还需要在服务器上托管一个名为“crossdomain.xml”的特殊文件,该文件启用此类脚本(Flash播放器将检查此内容。更多信息,请访问http://kb.adobe。 COM /自助服务/ viewContent.do?外部ID = tn_14213&sliceId = 2
The call is the easy part. :-) In the Flash code, you'll use the ExternalInterface to do the call, as documented here:
电话很容易。 :-)在Flash代码中,您将使用ExternalInterface进行调用,如下所示:
Short version: you say
简短版:你说
ExternalInterface.call("javascriptFunction", "argument")
#2
4
A common way to do this is with the ExternalInterface class, which you can use to call JavaScript methods.
执行此操作的常用方法是使用ExternalInterface类,您可以使用它来调用JavaScript方法。
First define your JavaScript methods, for example:
首先定义您的JavaScript方法,例如:
<script language="JavaScript">
function startsPlaying()
{
// do something when the FLV starts playing
}
</script>
Then modify your ActionScript to call the JavaScript method at the appropriate time:
然后修改ActionScript以在适当的时候调用JavaScript方法:
// inform JavaScript that the FLV has started playing
ExternalInterface.call("startsPlaying");
For more information, see the related Flash CS3 documentation.
有关更多信息,请参阅相关的Flash CS3文档。
#3
2
if you don't want to load
如果你不想加载
import flash.external.*;
so you can also do a
所以你也可以做一个
getUrl("javascript:startsPlaying();");