Embedding Movies with Flash, Part I: Basic Methods: Playing a Flash Movie - Doc JavaScript
Embedding Movies with Flash, Part I: Basic Methods
Playing a Flash Movie
In order to embed a Flash movie in your Web page, follow these two steps:
- Include the JavaScript include file,
flashmoviecheck.js
, in your header section:<SCRIPT LANGUAGE="JavaScript" SRC="flashmoviecheck.js"> </SCRIPT>
- Call
Flash_embed()
with yourSWF
file as a parameter. For example:Flash_embedSWF("swift3d.swf");
In order to play a Flash movie in your Web page, you need to follow these two steps:
- Create a JavaScript Flash object. We named the embedded Flash player
"sonify"
, in both Internet Explorer and Netscape Navigator. Therefore, you must use this name when creating the Flash object. You can name the object itself as you wish. We picked the namemySwf
:var mySwf = window.document.sonify;
- Call one of the many Flash methods that we start covering in this column. Here are two examples:
mySwf.Rewind(); mySwf.Play();
We already used one of the Flash methods (rewind()
) in flashmoviecheck.js
. The Flash player does not obey our assignment of AUTOSTART
to false
and the Flash movie autostarted when embedding. We put the following line in flashmoviecheck.js
to prevent the movie from autostarting:
window.document.sonify.Rewind();
We can embed a Flash movie and create a JavaScript Flash object in the same script:
<SCRIPT LANGUAGE="JavaScript"> Flash_embedSWF("swift3d.swf"); var mySwf = window.document.sonify; </SCRIPT>
Here are two links that demonstrate the above methods, Rewind()
and Play()
. The code is shown below the movie area. Play around with these links and see the impact on the following SWF, courtesy of www.swift3d.com. Notice that the Rewind()
method rewinds the video but not the audio track:
Here is the code for implementing the above links and Flash movie playing:
<SCRIPT LANGUAGE="JavaScript" SRC="flashmoviecheck.js"> </SCRIPT> <A href="javascript://" onclick="javascript:mySwf.Rewind(); return false">Rewind</A> | <A href="javascript://" onclick="javascript:mySwf.Play(); return false">Play</A> <SCRIPT LANGUAGE="JavaScript"> Flash_embedSWF("swift3d.swf"); var mySwf = window.document.sonify; </SCRIPT>
Next: How to jump to a certain frame
Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: June 4, 2001
Revised: June 4, 2001
URL: https://www.webreference.com/js/column85/3.html