admin管理员组文章数量:1353326
I have the following swf:
<head>
# load js
<script>
function graph() {
swfobject.embedSWF(
"open-flash-chart.swf", "chart", "400", "180", "9.0.0", "expressInstall.swf",
{"data-file":"{% url monitor-graph %}"});
};
</script></head>
<div id="chart"> </div>
<script>
graph();
</script>
I would like to call the graph function only if the swf has not been loaded yet, is there a way to do this? Thanks.
I have the following swf:
<head>
# load js
<script>
function graph() {
swfobject.embedSWF(
"open-flash-chart.swf", "chart", "400", "180", "9.0.0", "expressInstall.swf",
{"data-file":"{% url monitor-graph %}"});
};
</script></head>
<div id="chart"> </div>
<script>
graph();
</script>
I would like to call the graph function only if the swf has not been loaded yet, is there a way to do this? Thanks.
Share Improve this question asked Oct 15, 2010 at 5:06 Ruben QuinonesRuben Quinones 2,4728 gold badges26 silver badges30 bronze badges3 Answers
Reset to default 11Use SWFObject to embed the SWF, then use the callback function to poll the SWF's PercentLoaded
value.
If the value is 0, the SWF has not loaded yet. When it hits 100, the SWF is fully loaded.
Here's a tutorial for polling PercentLoaded
, plete with code examples.
The swfobject callback only returns success if the DOM element was successfully created. It doesn't actually say anything about whether or not the SWF has loaded.
From the swfobject documentation:
NOTE: success is report as true if the minimum Flash player required is available and that the Flash plugin-in DOM element for the SWF was created. SWFObject cannot detect if the swf file request has actually loaded or not.
The last argument to embedSWF
is a callback function that is invoked when the swf has been embedded. It takes in an event object with a couple of properties denoting success/failure, etc. More on this at the swfobject
documentation.
swfobject.embedSWF(
"open-flash-chart.swf", "chart", "400", "180", "9.0.0", "expressInstall.swf",
{"data-file":"{% url monitor-graph %}"}, {}, {},
function(e) {
if(e.success) graph();
}
);
本文标签: How to check if a swf is loaded using JavaScript with swfobjectStack Overflow
版权声明:本文标题:How to check if a swf is loaded using JavaScript with swfobject? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743889953a2556738.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论