3 Replies Latest reply on Mar 30, 2011 4:00 AM by kglad

    external SWF rate

    sbusig

      I am using loadMovieNum to place an external swf on the stage. it is unloaded via an on (release). another button loads the external swf again. when it is reloaded a second time the external swf seems to play faster. the external swf has the following script. both swfs are at 12 fps. any help would be appreciated.

       

      import mx.transitions.Tween;
      import mx.transitions.easing.Strong;

      this.createEmptyMovieClip("container2_mc",this.getNextHighestDepth());
      container2_mc._x = 216;
      container2_mc._y = 72;

      this.createEmptyMovieClip("container1_mc",this.getNextHighestDepth());
      container1_mc._x = 216;
      container1_mc._y = 72;

      this.attachMovie("loader","loader_mc",this.getNextHighestDepth());
      loader_mc._x = 342;
      loader_mc._y = 243;

      var myMCL:MovieClipLoader = new MovieClipLoader();
      var myListener:Object = new Object();
      myMCL.addListener(myListener);

      myListener.onLoadProgress = function(target,bytesLoaded,bytesTotal) {
      loader_mc._alpha = 100;
      var pct = Math.round(bytesLoaded/bytesTotal*100)
      loader_mc.bar_mc._xscale = pct;
      }

      myListener.onLoadComplete = function(target) {
      loader_mc._alpha = 0;
      fadeIn();
      }

      buttons_mc.attachMovie("prev","prev_mc",buttons_mc.getNextHighestDepth());
      buttons_mc.attachMovie("next","next_mc",buttons_mc.getNextHighestDepth());
      buttons_mc.next_mc._x = 684;
      buttons_mc.next_mc._y = 243;
      buttons_mc.prev_mc._x = 0;
      buttons_mc.prev_mc._y = 243;

      var numPics:Number = 7;
      var picArray:Array = new Array();
      var currentElement:Number = 0;
      var currentContainer:MovieClip = container1_mc;

      for (i=0;i < numPics;i++) {
      var location:String = "images/main/main_0" + (i+1) + ".jpg";
      picArray.push(location);
      }

      myMCL.loadClip(picArray[currentElement],container1_mc);

      buttons_mc.next_mc.onRelease = function() {
      nextPicture();
      clearInterval(myInterval);
      myInterval = setInterval(nextPicture,10000);
      }

      function nextPicture()
      {
      if (currentContainer == container1_mc) {
        currentContainer = container2_mc;
      }
      else
      {
        currentContainer = container1_mc;
      }

      currentContainer._alpha = 0;
      container1_mc.swapDepths(container2_mc);
      if (currentElement < picArray.length-1){
      currentElement++;
      }
      else
      {
        currentElement = 0;
      }
      myMCL.loadClip(picArray[currentElement],currentContainer);
      }

      buttons_mc.prev_mc.onRelease = function() {
      if (currentContainer == container1_mc) {
        currentContainer = container2_mc;
      }
      else
      {
        currentContainer = container1_mc;
      }

      currentContainer._alpha = 0;
      container1_mc.swapDepths(container2_mc);
      if (currentElement > 0){
        currentElement--;
      }
      else
      {
        currentElement = picArray.length-1;
      }
      myMCL.loadClip(picArray[currentElement],currentContainer);
      clearInterval(myInterval);
      myInterval = setInterval(nextPicture,10000);
      }

      function fadeIn() {
      new Tween(currentContainer,"_alpha",Strong.easeOut,0,100,48,false);
      }

      //--------------setInterval--------//
      myInterval = setInterval(nextPicture,10000);

        • 1. Re: external SWF rate
          kglad Adobe Community Professional & MVP

          make sure you're clearing all setIntervals() before unloading.

          • 2. Re: external SWF rate
            sbusig Level 1

            Not sure if this is the best method but it seems to work:

             

            In external SWF       _global.myInterval = setInterval(nextPicture,8000);

            In main SWF when called to reload external SWF      clearInterval(_global.myInterval);
                                                                                          loadMovieNum("main_interval.swf",1);

             

             

             

            If there is a better method any direction would be appreciated and thanks much for the input.

            • 3. Re: external SWF rate
              kglad Adobe Community Professional & MVP

              1.  clear each interval before setting.  (looks like you're already doing that.)

              2.  add each interval reference to an array when setting, remove when cleared

              3.  loop through the array before unloading to clear all existing intervals.

               

              p.s.  please mark helpful/correct answers.

              1 person found this helpful