spacer
Yehuda Shiran May 31, 2001
Rewinding a Flash Movie
Tips: May 2001

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

In some of your applications you may need to use Flash movies and JavaScript directly, without any prepackaged APIs such as FlashSound JavaScript API. You will enjoy more features, methods, and properties, but you'll have to take care of all the tiny details that are taken for granted when using FlashSound API, for example.

One of the "tiny" details is embedding the Flash object. The JavaScript file flashmoviecheck.js does exactly this, and other stuff. It also checks for Flash plug-ins, and minimum player version.

One of the problems of embedding Flash movies is that the movie starts automatically, even though we set the autostart parameter to false. The OBJECT tag looks like this in the include file flashmoviecheck.js:

document.writeln(
    '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
'codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0"' +
    'ID="sonify" WIDTH="100%" HEIGHT="100%">' +
    '<PARAM NAME="movie" VALUE="' + srcURL + '">' + 
    '<PARAM NAME="quality" VALUE="high">' +
    '<PARAM NAME="wmode" VALUE="transparent">'+
    '<PARAM NAME="autostart" VALUE="false">'+
    '<PARAM NAME="bgcolor" VALUE=' + bgcolor + '>' +

Notice the autostart parameter and its assigned value false. To overcome this problem, we added the following line as the last statement in Flash_embedSWF() function:

window.document.sonify.Rewind();

In this way, we rewind the SWF and stop it at the beginning of the track, ready to be played. Play around with the following SWF, courtesy of swift3d.com:

Rewind | Play

Here is the source code:

<SCRIPT LANGUAGE="JavaScript" SRC="flashmoviecheck.js"></SCRIPT>
<A href="javascript://" onclick="javascript:mySwf.Rewind(); return false">Rewind</A></FONT> | 
<A href="javascript://" onclick="javascript:mySwf.Play(); return false">Play</A></FONT>
<SCRIPT LANGUAGE="JavaScript">
  Flash_embedSWF("swift3d.swf");
  var mySwf = window.document.sonify;
</SCRIPT>


People who read this tip also read these tips:

Look for similar tips by subject:

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint