Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Flash Load Progress

Posted on 2006-05-25
2
Medium Priority
?
498 Views
Last Modified: 2012-06-22
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
Comment
Question by:splendorx
2 Comments
 
LVL 34

Accepted Solution

by:
Aneesh Chopra earned 1200 total points
ID: 16765841
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
 
LVL 1

Author Comment

by:splendorx
ID: 16770165
Thank you Aneesh!

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


Thanks,

Terry
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question