views:

29

answers:

1

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.

+1  A: 

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();
   }
 );
Jacob Relkin