June 4, 2001 - Superimposing Movies | WebReference

June 4, 2001 - Superimposing Movies

Yehuda Shiran June 4, 2001
Superimposing Movies
Tips: June 2001

Yehuda Shiran, Ph.D.
Doc JavaScript

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, as well as other stuff. For example, it checks whether a Flash player exists (Flash plug-in or ActiveX control), and whether its version is higher than the minimum required by the application.

Use the Flash method LoadMovie() to load a SWF file. The syntax is:

  LoadMovie(layerNumber, URL)
This method loads a given SWF (2nd argument) into the SWF object that the method belongs to. The parameter layerNumber designates the position of the new SWF with respect to other SWFs in the same page area. Set layerNumber to one to superimpose the new SWF on top of the previous SWF.

In this tip we preload swift3d.swf. You can see its traces in the window below. When you click the Load Movie link, another SWF, opener.swf (courtesy of www.associatesinscience.com), will be loaded on top of the previous SWF. Use the following links to play, rewind, and load opener.swf:

Rewind | Play | Load Movie

Here is the code:


<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> | 
<A href="javascript://" onclick="javascript:mySwf.LoadMovie(1, 'opener.swf'); return false">Load Movie</A>
<SCRIPT LANGUAGE="JavaScript">
  Flash_embedSWF("swift3d.swf");
  var mySwf = window.document.sonify;
</SCRIPT>