9 Replies Latest reply on Oct 19, 2008 4:43 PM by kglad

    Preloader percent

      Hi Group,
      I am creating a preloader that uses a mask to display part of a logo during load. However, the tutorial I found doesn't include a percentage text field. I would like to be able to add a dynamic text field labled something like text_percent and then have it dispaly the loading percentage along with mask. Below is the action script I am using for the mask portion. Can anyone help?

      rectMask_mc._height = 1;
      this.onEnterFrame = function():Void {
      var loadedData:Number = this.getBytesLoaded();
      var allData:Number = this.getBytesTotal();
      var percent:Number = Math.round(loadedData/allData*100);
      rectMask_mc._yscale = percent;
      if (loadedData >= allData) {
      gotoAndPlay("Scene 2", 1);
      delete this.onEnterFrame;
        • 1. Re: Preloader percent
          robdillon Most Valuable Participant
          Look at the online help example code for either getBytesLoaded or getBytesTotal. There is a a trace statement in the onEnterFrame function . You can place a textField on the stage and set its text property to the same string as that trace statement.
          • 2. Re: Preloader percent
            (getBytesTotal / BetBytesLoaded)*100
            that will give you the percentage of bytes loaded, just put that into a text field =]
            • 3. Re: Preloader percent
              Level 7
              >>(getBytesTotal / BetBytesLoaded)*100

              Just an FYI, but with operator precedence, / and * are the same. So the
              parenthesis is unnecessary, though still useful for a quick visual of the
              order you want. And those are functions:

              getBytesTotal() / getBytesLoaded() * 100;

              Dave -
              Head Developer
              Adobe Community Expert

              • 4. Re: Preloader percent
                tous0024 Level 1
                Hi Group,
                I am confused. I don't write Ascript... more of a copy paste thing and then I can kind of understand everything once I see it together. I am confused as to how and where this would be written into to initial Ascript I provided in the first post that contains my mask preloader... Also not sure how it is going to reference the Dynamic text field I created I would think it would have to be written something like: var percent:My_Dynamic_Field = getBytesTotal() / getBytesLoaded() * 100

                Everyone's help is greatly appreciated!
                • 5. Re: Preloader percent
                  tous0024 Level 1
                  Ok group, thanks for your help I figured out the % part of this... However, I have a new related question. On this pre-loader I also have part of the logo that reveals during the download using a mask. However I would like to have the mask semi-transparent to show the image and then it fills as the download progresses. I tried changing the alpha of the mask, but the mask is always 100% when testing. So the image doesn't show.

                  Is there a way to change the alpha of the maks so the part of the logo appears behind and then as the mask shrinks with the download it looks like the faded image is filling?

                  Thanks again for the help!
                  • 6. Re: Preloader percent
                    kglad Adobe Community Professional & MVP
                    enable the cacheAsBitmap properties of the mask and masked movieclips.
                    • 7. Re: Preloader percent
                      tous0024 Level 1
                      As you can probably tell by now I am not a flash expert. Ok, below is what I added to the Ascript for my preloader. However, no matter what I do to the mask movie clip (rectMask_mc), change the alpha or just set the opacity of the rectangle to 50%, it doesn't show transparent. It is all or nothing. I wish I could explain this better... anyways not sure what I am missing. Again, thanks for any assistance.

                      rectMask_mc.cacheAsBitmap = true;
                      • 8. Re: Preloader percent
                        Malborojones Level 1
                        If you want the transparency to be 50% write it the frame actions panel:
                        rectMask_mc._alpha = 50;
                        • 9. Re: Preloader percent
                          kglad Adobe Community Professional & MVP
                          you need to enable the cacheAsBitmap properties of BOTH the mask and masked movieclips.