4 Replies Latest reply on Apr 8, 2008 8:29 AM by dwallbaum

    MC progress bar


      I want to create a progress bar that shows how far the movie has progressed. The movie is a fairly long call center simulation, and some of these are 2 mins., some are 10 mins. or so. So and idea of where the user is in viewing this illustration would be useful.

      I am trying to crib from the Flash help file, and have come up with:

      var pctLoaded:Number = Math.round(mcMain._currentframe()/mcMain._totalframes()*100;
      bar_mc._xscale = pctLoaded;
      bar_mc._x = 0;
      bar_mc._y = 500;


      But that generates the following error:
      **Error** Scene=Scene 1, layer=action, frame=1:Line 63: ')' or ',' expected
      var pctLoaded:Number = Math.round(mcMain._currentframe()/mcMain._totalframes()*100;

      Total ActionScript Errors: 1 Reported Errors: 1

      What am I doing wrong, and if that script above is debugged, will it create a progress bar that increments and decrements as the user works through the MC?

      I will need to specify X-Y coordinates for the "bar_mc", but figure that is a simple:
      bar_mc._x = 0;
      bar_mc._y =500;

      Thank you for any thoughts.


        • 1. Re: MC progress bar
          dwallbaum Level 1
          OK, debugged my progress bar, with the slight problem that although I no longer get an error message when the script is checked, neither does anything happen.

          The following is in frame 1 of the Flash project. "mcMain" refers to content displayed in a scrollpane.

          Again, no errors are generated, but I don't see any progress bar either. Thanks!


          var pctLoaded:Number = Math.round(mcMain._currentframe/mcMain._totalframes)*100;
          bar_mc._xscale = pctLoaded;

          bar_mc._visible = true;
          • 2. Re: MC progress bar
            dwallbaum Level 1
            OK, found one issue: the bar is not updating. The code works,but as the movie progresses, the progress bar does not update.

            How to I prompt that?
            • 3. Re: MC progress bar
              Hi Don,

              You may need to put your update code onto a movieclip so it is updating every frame. If you have the code as is on the main timeline, it will run once, then not execute again.

              Select your bar_mc clip and use the following code:

              _visible = true;
              var pctLoaded:Number = Math.round((_parent.mcMain._currentframe/_parent.mcMain._totalframes)*100);
              _xscale = pctLoaded;

              *note that this assumes mcMain and bar_mc are both on the same level of the timeline (not nested within different clips)... otherwise change the _parent. to the path of the mcMain clip (_root.clip1.clip2.mcMain).

              Hope that helps!
              • 4. Re: MC progress bar
                dwallbaum Level 1

                You nailed it!!!

                Dropped the code on the bar_mc movie clip and it ran perfectly.

                A !!!!!!!!!!!!! MILLION !!!!!!!!!!!!!!!! thank yous!!!!!!!!!!!