3 Replies Latest reply on Jan 13, 2011 8:01 AM by yalp.com.br

    Calculating progress bar size

    yalp.com.br

      Hi guys,

      I'm having some problems trying to calculate the size of a progress bar.

      Here is the thing I have a movie with X scenes and I want the progress  bar to fill up according to the porcentage of my timeline that has  passed.

      here is the code I'm using

      var parcialSeek
      var completeSeek

      this.addEventListener(Event.ENTER_FRAME, tamanhoBarra)
      function tamanhoBarra(e:Event):void{
           completeSeek = vid_mc.totalFrames // vid_mc is the movie clip that loads my external SWF
           parcialSeek = vid_mc.currentFrame / vid_mc.totalFrames
           seek_mc.seekBar_mc.scaleX = parcialSeek
      }

      with this code every new scene the bar starts again and since I don't  have exacts 100 frames on my movie the bar size dosen't match?

      can anyone please help? thanks a lot for the atention!!

        • 1. Re: Calculating progress bar size
          kglad Adobe Community Professional & MVP

          movieclip's don't load anything in as3.  if vid_mc = MovieClip(yourloader.content), use:

           

          this.addEventListener(Event.ENTER_FRAME, tamanhoBarra);
          var previousframes:uint=0;
          var sceneframe:uint=0;

           

          function tamanhoBarra(e:Event):void{
               completeSeek = vid_mc.totalFrames // vid_mc is the movie clip that loads my external SWF
               if(vid_mc.currentFrame==1){
                   previousframes += sceneframe;
               }
               parcialSeek = (previousframes+sceneframe)/vid_mc.totalFrames
               seek_mc.seekBar_mc.scaleX = parcialSeek
               sceneframe=vid_mc.currentFrame;
          }

          1 person found this helpful
          • 2. Re: Calculating progress bar size
            yalp.com.br Level 1

            thanks again for your help!!

             

            the code works, the only problem is when I skip a scene the bar goes to 0 and not the porcentage of the totalFrames viewed, and when the scenes change the bar clicks (it fills up and comes back to position, understand?)

             

            I have a total amount of frames on my SWF I need the bar to show the porcentage of the movie that is been seen.

             

            best regards!