# AS2 Scratch Card

**URL:** <https://forum.kirupa.com/t/as2-scratch-card/316228>\
**Category:** flash\
**Created:** [November 16, 2010, 11:25am UTC](https://forum.kirupa.com/t/as2-scratch-card/316228 "2010-11-16T11:25:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![luuxedotnl](https://avatars.discourse-cdn.com/v4/letter/l/ecccb3/32.png) [@luuxedotnl](https://forum.kirupa.com/u/luuxedotnl)\
**Post date:** [November 16, 2010, 11:25am UTC](https://forum.kirupa.com/t/as2-scratch-card/316228/1 "2010-11-16T11:25:03Z")

</div>

Hi All,

I’ve a problem. I used a script on the internet to create a scratchcard and this worked fine. But i want to and a command gotoAndPlay when the scratchcard is scratched. Does anyone know a working method?

This is the code:

this.createEmptyMovieClip(‘mask\_mc’,0);  
bg\_mc.setMask(mask\_mc);  
var contor:Number=0;

// function drawCircle draws a circle on mask\_mc MovieClip of radius r and having center to mouse coordinates  
function drawCircle(mask\_mc:MovieClip):Void{  
var r:Number = 20;  
var xcenter:Number = \_xmouse;  
var ycenter:Number = \_ymouse;  
var A:Number = Math.tan(22.5 \* Math.PI/180);  
var endx:Number;  
var endy:Number;  
var cx:Number;  
var cy:Number;

mask\_mc.beginFill(0x000000, 100);  
mask\_mc.moveTo(xcenter+r, ycenter);  
for (var angle:Number = Math.PI/4; angle\<=2_Math.PI; angle += Math.PI/4) {  
xend = r_Math.cos(angle);  
yend = r\*Math.sin(angle);

xbegin =xend + r\* A _Math.cos((angle-Math.PI/2));  
ybegin =yend + r_ A \*Math.sin((angle-Math.PI/2));  
mask\_mc.curveTo(xbegin+xcenter, ybegin+ycenter, xend+xcenter, yend+ycenter);  
}  
mask\_mc.endFill();  
}

// contor variable is used to hold if the mouse is pressed (contor is 1) or not (contor is 0)  
this.onMouseDown=function(){  
drawCircle(mask\_mc);  
contor=1;  
}

// if the mouse is hold and moved then we draw a circle on the mask\_mc  
this.onMouseMove=this.onEnterFrame=function(){  
if (contor==1){  
drawCircle(mask\_mc);  
}  
}  
this.onMouseUp=function(){  
contor=0;  
}
