Hi,
I have encountered this weird problem that my mask sometimes work and sometimes
doesn’t. I’m using an animated movieclip, then cache as bitmap. I tried a lot of ways to
see what’s wrong, but I still couldn’t find out the problem. Here’s my code, thanks
I’ll talk a little bit about my code,
I added a loader to the stage
addChild(animcontent2);
maskfunc1(animcontent2);
After loaded, the mask is triggered. The thing is that I have a button that reloads the loader
every time when someone clicks on it, but the mask doesn’t show every time, it seems pretty
random…
private function maskfunc1(aa):void {
aa.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
aa.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
}
private function loadProgress(e:ProgressEvent):void {
var percent:Number = e.bytesLoaded/e.bytesTotal;
per.visible = true;
per.text = Math.ceil(percent * 100).toString();
}
private function loadComplete(e:Event):void {
per.visible = false;
mask1.gotoAndPlay(1);
mask1.cacheAsBitmap = true;
e.target.loader.cacheAsBitmap = true;
e.target.loader.mask=mask1;
}
thanks again!