// makeswf -o hitMask.swf hitMask.as // Draw a circle with given center and radius // Uses 8 curves to approximate the circle MovieClip.prototype.drawCircle = function (x, y, rad, color) { where = this; var ctl = Math.sin(24*Math.PI/180)*rad; var cos = Math.cos(45*Math.PI/180)*rad; var sin = Math.sin(45*Math.PI/180)*rad; with (where) { beginFill(color, 100); lineStyle(1, 0); moveTo(x, y-rad); curveTo(x+ctl, y-rad, x+cos, y-sin); curveTo(x+rad, y-ctl, x+rad, y); curveTo(x+rad, y+ctl, x+cos, y+sin); curveTo(x+ctl, y+rad, x, y+rad); curveTo(x-ctl, y+rad, x-cos, y+sin); curveTo(x-rad, y+ctl, x-rad, y); curveTo(x-rad, y-ctl, x-cos, y-sin); curveTo(x-ctl, y-rad, x, y-rad); endFill(); } }; // Draw a rect with given offset and size MovieClip.prototype.drawRect = function (x, y, width, height, color) { where = this; with (where) { beginFill(color, 100); lineStyle(1, 0); moveTo(x, y); lineTo(x, y+height); lineTo(x+width, y+height); lineTo(x+width, y); lineTo(x, y); endFill(); } }; createEmptyMovieClip('a', 1); a.drawCircle(150, 150, 100, 0xFF0000); a.onRollOver = function() {}; createEmptyMovieClip('b', 2); b.drawRect(100, 100, 100, 100, 0x00FF00); a.setMask(b);