Autostart a swf video with swfobject

1.5k Views Asked by At

I have a video that loads when you click on an image, the problem is the video does not autoplay so you have to click twice. I would like this video to autoplay when I click the image. Thanks in advance

<tr>
    <td class="filmbodyplay" height="50" align="right" valign="top">
      <a href="#" onclick="playMovie( this, 'https://www.capcomfcu.org/images/stories/security-center/swf/phishing.swf' );" >
            <img src="https://www.capcomfcu.org/images/stories/security-center/phishing.jpg" border="0" alt="play" />
      </a>
    </td>
</tr>
<script type="text/javascript">
swfobject.registerObject("FlashID");
</script>

header code

<script src="Scripts/swfobject_modified.js" type="text/javascript"></script>
<script type="text/javascript">
function playMovie( a, href ) {

    // remove element if exists
    var container   = document.getElementById( "playing" );
    var flash_movie = document.getElementById( "flash_movie" );

    if( flash_movie ) {
        container.removeChild( flash_movie );
    }   

    // create new element
    var embed = document.createElement( "EMBED" );
    embed.setAttribute( "allowFullScreen", "true" );
    embed.setAttribute( "autostart", "true");
    embed.setAttribute( "src", href );
    embed.setAttribute( "type", "application/x-shockwave-flash" );
    embed.setAttribute( "width", "480" );
    embed.setAttribute( "height", "360" );
    embed.setAttribute( "id", "flash_movie" );

    // clear out the cell
    cell = a.parentNode;
    cell.id = 'playing';

    while( cell.hasChildNodes() ) {
        cell.removeChild( cell.firstChild );
    }

    // insert the element into the cell
    cell.appendChild( embed );

}


</script>
1

There are 1 best solutions below

1
On

Looks like when using an embed tag the attribute to start play immediately upon loading is play (http://helpx.adobe.com/flash/kb/flash-object-embed-tag-attributes.html), but it defaults to true. I'm wondering if your swf has a loader in the main timeline in which case you would need to place some action-script to start play automatically.