Embedding Movies with Flash, Part I: Basic Methods: Checking Progress of Embedding and Playing - Doc JavaScript | WebReference

Embedding Movies with Flash, Part I: Basic Methods: Checking Progress of Embedding and Playing - Doc JavaScript


Embedding Movies with Flash, Part I: Basic Methods

Checking Progress of Embedding and Playing

There are several methods that may help you to determine the progress of your Flash movie. We'll cover two of them here, one for finding the playing status of a Flash movie, and one for finding the embedding progress of a movie. Use the Flash method IsPlaying() to find out if a Flash movie is playing. The syntax is:

IsPlaying()

The method returns true if the movie is currently playing. The following links demonstrate how to play a movie, how to rewind it, and how to find whether the movie is playing. Click the Play link and, while the movie is playing, click the Is Playing? link. See how the alert box prints true when the movie is playing, and false before you start the movie and after it ends.

Rewind | Play | Is Playing?

Here is the code:

<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:alert(mySwf.
  IsPlaying()); return false">Is Playing?</A>
<SCRIPT LANGUAGE="JavaScript">
  Flash_embedSWF("opener.swf");
  var mySwf = window.document.sonify;
</SCRIPT>

Use the Flash method PercentLoaded() to find out the percentage of the Flash movie that is already loaded. The syntax is:

PercentLoaded()

This method returns the percent of the Flash movie that has streamed into the browser so far. Possible values are from 0 to 100. Some movies are loaded instantly, and PercentLoaded() returns 100% as soon as you call Flash_embedSWF(). We still have not come across a Flash movie that will yield PercentLoaded() less than 100%, but it depends on the system you have, the modem's speed, etc.

This demo lets you play, rewind, and find the movie's percent loaded.

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:alert(mySwf.
  PercentLoaded()); return false">Percent Loaded</A>
<SCRIPT LANGUAGE="JavaScript">
  Flash_embedSWF("swift3d.swf");
  var mySwf = window.document.sonify;
</SCRIPT>

Next: How to replace and superimpose a second movie

http://www.internet.com


Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: June 4, 2001
Revised: June 4, 2001

URL: http://www.webreference.com/js/column85/5.html