This codes in Actionscript-2, Can anyone help me translate it into AS-3 please ?.......a newby pulli
Posted
by Spux
on Stack Overflow
See other posts from Stack Overflow
or by Spux
Published on 2010-04-14T18:49:43Z
Indexed on
2010/04/14
19:03 UTC
Read the original article
Hit count: 462
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;
}
© Stack Overflow or respective owner