• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 500
  • Last Modified:

Flash Load Progress

I have attempted to use two seperate scripts to determine if a SWF is loaded, but niether work.  The scripts are found in O'Reilly's Actionscript Cookbook on page 487 or can be found at:

http://ascook.tar.hu/actscptckbk-chp-15-sect-10.html

I am stumped on how to determine if a SWF has loded successfully.  Please advise on what needs to be changed in below script.  Thanks!

// Create a movie clip and begin loading a .swf file into it.
_root.createEmptyMovieClip("swfHolder", 1);
swfHolder.loadMovie("http://www.tadstudios.com/oma/davinci.swf");

// Define a function to call at an interval.
function monitor (  ) {
  // Execute trace(  ) once the .swf file has finished loading.
  if (swfHolder.isLoaded) {
    trace("SWF has loaded");
  }
};

// Invoke monitor(  ) every 100 milliseconds to update the load status.
monitorInterval = setInterval("monitor", 100);
/////////////////////////////////////////////////
// Second script
///////////////////////////////////////////////
// Create a movie clip and begin loading a .swf file into it.
_root.createEmptyMovieClip("swfHolder", 1);
swfHolder.loadMovie("http://www.tadstudios.com/oma/davinci.swf");

// Create a movie clip to monitor the load progress.
_root.createEmptyMovieClip("loadMonitorMc", 2);

// Define an onEnterFrame(  ) method for the monitor movie clip.
loadMonitorMc.onEnterFrame = function (  ) {

  // Execute trace(  ) once the .swf file has finished loading.
  if (_root.swfHolder.isLoaded) {
    trace("SWF has loaded");
  }
};
0
splendorx
Asked:
splendorx
1 Solution
 
Aneesh ChopraCommented:
Hi,

below is the fixed code for both scripts

here is the fixed code for one script:
----------
/////////////////////////////////////////////////
// First script
///////////////////////////////////////////////
// Create a movie clip and begin loading a .swf file into it.
_root.createEmptyMovieClip("swfHolder", 1);
swfHolder.loadMovie("http://www.tadstudios.com/oma/davinci.swf");

// Define a function to call at an interval.
function monitor (  ) {
  // Execute trace(  ) once the .swf file has finished loading.
  if (_root.swfHolder.getBytesTotal() == _root.swfHolder.getBytesLoaded() && _root.swfHolder._width>0){
    trace("SWF has loaded");
  }
};

// Invoke monitor(  ) every 100 milliseconds to update the load status.
monitorInterval = setInterval("monitor", 100);
///////////////////////////////////////////////


here is the fixed code for second script:
----------
/////////////////////////////////////////////////
// Second script
///////////////////////////////////////////////
// Create a movie clip and begin loading a .swf file into it.
_root.createEmptyMovieClip("swfHolder", 1);
swfHolder.loadMovie("http://www.tadstudios.com/oma/davinci.swf");

// Create a movie clip to monitor the load progress.
_root.createEmptyMovieClip("loadMonitorMc", 2);

// Define an onEnterFrame(  ) method for the monitor movie clip.
loadMonitorMc.onEnterFrame = function (  ) {

  // Execute trace(  ) once the .swf file has finished loading.
  if (_root.swfHolder.getBytesTotal() == _root.swfHolder.getBytesLoaded() && _root.swfHolder._width>0){
      trace("SWF has loaded");
  }
};
///////////////////////////////////////////////

Rgds
Aneesh
0
 
splendorxAuthor Commented:
Thank you Aneesh!

The first script was not working for some reason; however, the second script works fine.


Thanks,

Terry
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now