PDA

View Full Version : mask doesn't work all the time



christinelalala
January 8th, 2009, 01:53 PM
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(ProgressEven t.PROGRESS, loadProgress);
aa.contentLoaderInfo.addEventListener(Event.COMPLE TE, 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!

GrndMasterFlash
January 8th, 2009, 05:42 PM
stabbing in the dark here.....

are you removing the old object after the new one gets loaded? maybe the mask is having memory issues