7 Replies Latest reply on Apr 7, 2009 3:54 PM by kglad

    External png as mask

      I have several pngs I need to load as masks. The user will be making different selections that requires

      these to be external images. I've managed to get the png working as a mask just fine when I physically

      place it on the timeline and assign cacheAsBitmap=true to both it and the mc to be masked. But when I

      try to load the png using loadMovie... it no longer behaves as a mask... any clues gents?

       

      Thanks in advance,

      jH

        • 1. Re: External png as mask
          kglad Adobe Community Professional & MVP

          did you enable the cacheAsBitmap property of the target movieclip AFTER loading was complete?

          • 2. Re: External png as mask
            Level 1

            Yes, I thought of that and made sure I set cacheAsBitmap after I loaded the png.... still no go

            • 3. Re: External png as mask
              kglad Adobe Community Professional & MVP

              if you set your mask and enable cacheAsBitmap AFTER loading is complete, there is no problem.

               

              if you think you're doing that and having a problem, copy and paste your relevant code.

              • 4. Re: External png as mask
                Level 1

                Thanks for the help kglad, I greatly appreciate it, as this has had me pulling my hair out...

                Here's the AS I'm using:

                 

                 

                this.createEmptyMovieClip("mask", this.getNextHighestDepth());
                mask.loadMovie("masks/sorrento_frame_mask.png");
                mask.cacheAsBitmap=true;
                color.cacheAsBitmap=true;
                color.setMask(mask);

                 

                In the actual application I'm using nested movie clips, this is just a basic

                example I'm working with, first to see if there was a problem with the

                nested clips... which there wasn't, they worked fine as long as the

                png was physically on the timeline.

                • 5. Re: External png as mask
                  kglad Adobe Community Professional & MVP

                  that's going to fail.  you're not waiting until AFTER loading is complete to apply setMask() and enable cacheAsBitmap:

                   

                  this.createEmptyMovieClip("mask", this.getNextHighestDepth());

                  mask.loadMovie("masks/sorrento_frame_mask.png");

                  this.onEnterFrame = loadProgressF;

                   

                  function loadProgressF(){

                  if(mask.getBytesLoaded()>0&&mask.getBytesLoaded()>=mask.getBytesTotal()){

                  mask.cacheAsBitmap=true;
                  color.cacheAsBitmap=true;  // this can be done before loading is complete, but not the other lines of code
                  color.setMask(mask);

                  delete this.onEnterFrame;

                  }

                  }
                  • 6. Re: External png as mask
                    Level 1

                    Thanks man, I see what I was doing wrong now. I actually wound up using the MovieClipLoader class with a listener

                    and that did the trick. Thanks again for your help!

                     

                    jH

                    • 7. Re: External png as mask
                      kglad Adobe Community Professional & MVP

                      you're welcome.