2 Replies Latest reply on Aug 27, 2007 1:06 PM by StupidHuman

    movie clips stop rotating

    StupidHuman
      I have a rotating image (swf files) array on Apple Site that is displaying properly, but dies after an indeterminate amount of time. I have no idea why the bitmaps aren't being cached so that the files would continue to appear. There is no logical explanation for the script to just stop displaying, there is no limiting variable to stop the display. code is:

      import flash.filters.BlurFilter;
      stop();
      var myMCL:MovieClipLoader = new MovieClipLoader();
      filename = ["Curealty_MC", "fetch2_MC", "homepossible_MC", "treasure_MC", "sterling_MC"];
      path = " http://www.applefcu.org/flash/";
      counter=1;
      currentTop=0;
      i = filename.length;
      //Get the percentage loaded of the next image
      function getPercentLoaded(){
      return(100*eval("displayImage"+currentTop).getBytesLoaded()/eval("displayImage"+currentTo p).getBytesTotal());
      }
      //Reset the delay counter, swap the images in depth, and make the top invisible
      function nextImage(){
      counter=72;
      currentTop=(currentTop+1)%2;
      eval("displayImage"+currentTop).swapDepths(eval("displayImage"+(currentTop+1)));
      eval("displayImage"+currentTop)._alpha=0;
      return currentTop;
      }
      onEnterFrame=function(){
      counter--;
      //if the delay counter hits 0, load the next image
      if(counter==0){
      //random number generated
      k = Math.floor(Math.random()*i);
      //checks existing position in array to eliminate immediate duplicate image
      if(p==k){
      if(k==5){
      k=0;
      }else{
      k++;
      }
      }
      myMCL.loadClip(filename[k], eval("displayImage"+nextImage()));
      Trace (filename[k]);
      }
      //start the transition after the next image has loaded
      if(eval("displayImage"+currentTop)._alpha!=100){
      Trace(eval("displayImage"+currentTop)._alpha);
      eval("displayImage"+currentTop).getNextHighestDepth();
      if(eval("displayImage"+currentTop)._alpha<100 && eval("displayImage"+currentTop).getBytesLoaded()==eval("displayImage"+currentTop).getByte sTotal() && eval("displayImage"+currentTop).getBytesLoaded()>0 ){
      //quality of the blur
      quality = 2;
      p = k;
      //The next 4 lines apply a blur to the transition. Remove these lines if the applet runs slow
      var filter:BlurFilter = new BlurFilter(eval("displayImage"+((currentTop+1)))._alpha, eval("displayImage"+((currentTop+1)))._alpha, quality);
      eval("displayImage"+currentTop).filters=[filter];
      var filter2:BlurFilter = new BlurFilter(eval("displayImage"+currentTop)._alpha, eval("displayImage"+currentTop)._alpha, quality);
      eval("displayImage"+((currentTop+1))).filters=[filter2];
      //fade one in and one out
      eval("displayImage"+currentTop)._alpha+=4;
      eval("displayImage"+((currentTop+1)))._alpha-=4;
      //image is still loading
      Trace (currentTop);
      }else if(eval("displayImage"+currentTop).getBytesLoaded()!=eval("displayImage"+currentTop).getB ytesTotal()){
      counter=72;
      }
      }
      }
        • 1. Re: movie clips stop rotating
          clbeech Level 3
          lloks like the problem is with the random check sequence. 'p' has not been declared previous to the first loop iteration (but this is imaterial because the loop wil continue as p=undefined not satisfing the condition), and increamenting k, if k does not equal 5? maybe write this check as:

          while(p==k) {
          k = Math.round(Math.random()*(i - 1));
          }

          k will never equal anything outside the length of the array, and always return a value that doesn't equal current p. But declare the two equal at the top of your script to initiate the choice:

          var p:Number = 0;
          var k:Number = 0;
          • 2. Re: movie clips stop rotating
            StupidHuman Level 1
            The five is actually because there was a fifth element in the array before. I have since removed it.