I'm trying to make a window-cleaning game with flash as3 on the timeline. (Sounds boring I know, but I realy have some fun idea's with it)
So I have: A dirtywindow movieclip on the bottom layer and a clean window movieclip on layer 2(mc1) on the layer above.
To hide the top layer(the dirty window) I assign a mask to it.
// this creates a mask that hides the movieclip on top
var mask_mc:MovieClip = new MovieClip();
addChild(mask_mc)
//assign the mask to the movieclip it should 'cover'
mc1.mask = mask_mc;
With a brush(cursor) the player wipes of the dirt ( actualy setting the fill from the mask to transparent so the clean window appears)
//add event listeners for the 'brush'
brush_mc.addEventListener(MouseEvent.MOUSE_DOWN,brushDown);
brush_mc.addEventListener(MouseEvent.MOUSE_UP,brushUp);
//function to drag the brush over the mask
function brushDown(dragging:MouseEvent):void{
dragging.currentTarget.startDrag();
MovieClip(dragging.currentTarget).addEventListener(Event.ENTER_FRAME,erase) ;
mask_mc.graphics.moveTo(brush_mc.x,brush_mc.y);
}
//function to stop dragging the brush over the mask
function brushUp(dragging:MouseEvent):void{
dragging.currentTarget.stopDrag();
MovieClip(dragging.currentTarget).removeEventListener(Event.ENTER_FRAME,erase);
}
//fill the mask with transparant pixels so the movieclip turns visible
function erase(e:Event):void{
with(mask_mc.graphics){
beginFill(0x000000);
drawRect(brush_mc.x,brush_mc.y,brush_mc.width,brush_mc.height);
endFill();
}
}
I hope you can help me with the following problem: The game-aspect of this should be the points the player get's for cleaning/erasing all the dirt.
Can anyone tell me how I can check if all pixels are set to transparency? So how to check if all the dirt has been erased? And than for example trace ("window cleaned")
I tried the compare() function but didn't have much luck with it :(...
