4 Replies Latest reply on Mar 25, 2011 7:23 AM by Flanders_ZA

    MovieClipLoader and checking whether clip was previously loaded

    Flanders_ZA

      Hi,

       

      I'm using a preloader and MovieClipLoader to seemingly good effect and I have an ending sequence to my preloader where it plays out once the target clip is loaded. The ending sequence features within the preloader itself (preloader_mc.endingClip). preloader_mc plays through its frames with:

       

      function onLoadProgress(target, loadedBytes, totalBytes){
      target.stop();
      target._visible = false;
      var StepUpBytes = totalBytes/100;
      stepFrame = Math.floor(loadedBytes/StepUpBytes);
      if(stepFrame<1){
        stepFrame = 1;
      }
      preloader_mc.gotoAndStop(stepFrame+1); 
      }

       

      until it gets to 100% and then gets to a frame telling endingClip to play. All good unless the target clip is already loaded. Then what happens is that the preloader jumps to 100% and only plays the ending sequence. I would like to have a way of checking to see if the target clip has already been loaded so as to avoid displaying only this ending portion of the preloader.

       

      In onLoadProgress I tried:

       

      if((loadedBytes == totalBytes) && (target._width > 0)){
        preloader_mc.removeMovieClip();
      }

       

      This isn't working but I'm confused because for each of my targets I have an empty clip and when a new one is loaded, the current one is made _visible = false. I therefore thought the (target._width > 0) bit would work since the empty clip would already house the target? Trace returns zero for width value and returns different values for loadedBytes and totalBytes even if I revisit a freshly loaded clip.

       

      The loadClip is triggered by an onPress event as described here:

       

      navMenu.navClip.Section3But.onPress = function  () {
      startPreload("flash/construction.swf");
      function startPreload(url){
        loader_mcl.loadClip(url, ConstructionClip);
          }
      this.enabled = false;
      onEnterFrame = function (){
        PropDevClip._visible=false;
        ProjManClip._visible=false;
        DesignClip._visible=false;
        delete onEnterFrame;
      }