Symbol 31 MovieClip Frame 1
play();
Symbol 31 MovieClip Frame 3
gotoAndPlay (1);
Symbol 33 MovieClip Frame 1
SCRATCH_USE_COIN = 2;
SCRATCH_HIDE_CURSOR = 1;
SCRATCH_PUSH_RADIUS = 40;
SCRATCH_PUSH_POWER = 100;
SCRATCH_PUSH_X = 20;
SCRATCH_PUSH_Y = 20;
SCRATCH_RESISTANCE = 0.8;
SCRATCH_GRAVITY = 5;
SCRATCH_PARTICLE_GENERATION = 3;
SCRATCH_PARTICLE_SPREAD = 10;
SCRATCH_PARTICLE_SPREAD_X = 5;
SCRATCH_PARTICLE_SPREAD_Y = 5;
SCRATCH_MAX_PARTICLE = 500;
SCRATCH_VERIFICATION_X = 12;
SCRATCH_VERIFICATION_Y = 12;
SCRATCH_VERIFICATION_THRESHOLD = 0.01;
SCRATCH_REVEAL_SPEED = 10;
SCRATCH_FADE_EVERYTHING = false;
SCRATCH_WIN_CHANCE = 0.5;
SCRATCH_WIN_TIMING = 90;
runWin = function () {
};
runLose = function () {
};
function checkForCollision(p_clip1, p_clip2, p_alphaTolerance, X, Y, shape) {
var _local3 = new flash.display.BitmapData(p_clip2.width, p_clip2.height, false, 16777215);
var _local1 = new flash.geom.Matrix();
_local1.tx = X;
_local1.ty = Y;
if (X <= 100) {
a = 1;
}
_local3.draw(shape, _local1);
_local1.tx = 0;
_local1.ty = 0;
_local3.draw(p_clip2, _local1, new flash.geom.ColorTransform(1, 1, 1, 1, 255, -255, -255, 255));
var _local2 = _local3.getColorBoundsRect(4294967295, 4278190080);
if (_local2.width == 0) {
return(null);
}
_local2.x = _local2.x + bounds.xMin;
_local2.y = _local2.y + bounds.yMin;
return(_local2);
}
scratch_count = 0;
scratch_down = false;
particle_count = 0;
if (Math.random() <= SCRATCH_WIN_CHANCE) {
this.result.gotoAndStop(1);
} else {
this.result.gotoAndStop(2);
}
this.attachMovie("scratch_mask", "scratch_mask", this.getNextHighestDepth());
this.scratch_mask.fade._xscale = this.result._width;
this.scratch_mask.fade._yscale = this.result._height;
this.scratch_mask.fade.gotoAndStop(2);
this.result.setMask(this.scratch_mask);
var scratch_bmd = (new flash.display.BitmapData(this.result._width, this.result._height, true, 16711935));
var scratch_bmd2 = (new flash.display.BitmapData(this.result._width, this.result._height, true, 16711935));
this.scratch_mask.attachBitmap(scratch_bmd, this.scratch_mask.getNextHighestDepth());
this.scratch_mask.cacheAsBitmap = true;
this.result.cacheAsBitmap = true;
var myMatrix = (new flash.geom.Matrix());
this.surface._width = this.result._width;
this.surface._height = this.result._height;
if (SCRATCH_USE_COIN == 0) {
this.coin._visible = false;
} else {
this.coin.gotoAndStop(1);
}
if (SCRATCH_HIDE_CURSOR != 0) {
Mouse.hide();
}
this.shape._visible = false;
this.onEnterFrame = function () {
moveParticle();
pushParticle();
};
this.onMouseMove = function () {
if (scratch_down) {
scratch();
}
if (SCRATCH_USE_COIN == 2) {
this.coin._x = (this.shape._x = this._xmouse);
this.coin._y = (this.shape._y = this._ymouse);
}
if (this.result.hitTest(_root._xmouse, _root._ymouse)) {
if (SCRATCH_USE_COIN == 1) {
this.coin._x = (this.shape._x = this._xmouse);
this.coin._y = (this.shape._y = this._ymouse);
}
if ((SCRATCH_HIDE_CURSOR == 1) && (this.revealed != true)) {
Mouse.hide();
}
} else if (SCRATCH_HIDE_CURSOR == 1) {
Mouse.show();
}
updateAfterEvent();
};
this.onMouseDown = function () {
scratch_down = true;
if (SCRATCH_USE_COIN != 0) {
this.coin.gotoAndStop(2);
}
};
this.onMouseUp = function () {
scratch_down = false;
if (SCRATCH_USE_COIN != 0) {
this.coin.gotoAndStop(1);
}
};
scratch = function () {
scratch_collision = checkForCollision(this.scratch_bmd2, this.scratch_bmd, 255, this._xmouse, this._ymouse, this.shape);
if (scratch_collision == null) {
return(undefined);
}
scratch_collision_force = (scratch_collision.height * scratch_collision.width) / (this.shape._width * this.shape._height);
particle_count = particle_count + (scratch_collision_force * SCRATCH_PARTICLE_GENERATION);
while (particle_count >= 1) {
particle_count--;
spawnParticle();
}
myMatrix.tx = this._xmouse;
myMatrix.ty = this._ymouse;
this.scratch_bmd.draw(this.shape, myMatrix);
scratch_verif_count = 0;
scratch_i = 0;
while (scratch_i <= (SCRATCH_VERIFICATION_X - 1)) {
scratch_j = 0;
while (scratch_j <= (SCRATCH_VERIFICATION_Y - 1)) {
if (this.scratch_bmd.getPixel32((scratch_i + 1) * (this.result._width / (SCRATCH_VERIFICATION_X + 1)), (scratch_j + 1) * (this.result._height / (SCRATCH_VERIFICATION_Y + 1))) == 0) {
scratch_verif_count++;
}
scratch_j++;
}
scratch_i++;
}
if (SCRATCH_VERIFICATION_THRESHOLD >= (scratch_verif_count / (SCRATCH_VERIFICATION_X * SCRATCH_VERIFICATION_Y))) {
runReveal();
if (SCRATCH_FADE_EVERYTHING) {
fadeAll();
}
}
};
spawnParticle = function () {
this.particles["scratch_particle" + scratch_count].removeMovieClip();
this.particles.attachMovie("scratch_particle", "scratch_particle" + scratch_count, this.particles.getNextHighestDepth());
this.particles["scratch_particle" + scratch_count]._x = ((this._xmouse + SCRATCH_PARTICLE_SPREAD_X) + (Math.random() * SCRATCH_PARTICLE_SPREAD)) - (SCRATCH_PARTICLE_SPREAD / 2);
this.particles["scratch_particle" + scratch_count]._y = ((this._ymouse + SCRATCH_PARTICLE_SPREAD_Y) + (Math.random() * SCRATCH_PARTICLE_SPREAD)) - (SCRATCH_PARTICLE_SPREAD / 2);
this.particles["scratch_particle" + scratch_count].vx = 0;
this.particles["scratch_particle" + scratch_count].vy = 0;
this.particles["scratch_particle" + scratch_count].gotoAndStop(Math.ceil((Math.random() * 9.9) + 0.1));
this.particles["scratch_particle" + scratch_count]._rotation = Math.random() * 360;
scratch_count++;
if (scratch_count >= (SCRATCH_MAX_PARTICLE - 1)) {
scratch_count = 0;
this.particles.scratch_particle0.removeMovieClip();
}
};
pushParticle = function () {
scratch_i = 0;
while (scratch_i <= SCRATCH_MAX_PARTICLE) {
temp_scratch_dist = Math.max(0, SCRATCH_PUSH_RADIUS - Math.sqrt(Math.pow(this.particles["scratch_particle" + scratch_i]._x - (this._xmouse + SCRATCH_PUSH_X), 2) + Math.pow(this.particles["scratch_particle" + scratch_i]._y - (this._ymouse + SCRATCH_PUSH_Y), 2)));
if (temp_scratch_dist >= 0.01) {
temp_scratch_power = temp_scratch_dist / SCRATCH_PUSH_RADIUS;
temp_scratch_angle = Math.atan2(this.particles["scratch_particle" + scratch_i]._y - (this._ymouse + SCRATCH_PUSH_Y), this.particles["scratch_particle" + scratch_i]._x - (this._xmouse + SCRATCH_PUSH_X));
this.particles["scratch_particle" + scratch_i].vx = this.particles["scratch_particle" + scratch_i].vx + ((temp_scratch_power * SCRATCH_PUSH_POWER) * Math.cos(temp_scratch_angle));
this.particles["scratch_particle" + scratch_i].vy = this.particles["scratch_particle" + scratch_i].vy + ((temp_scratch_power * SCRATCH_PUSH_POWER) * Math.sin(temp_scratch_angle));
}
scratch_i++;
}
};
moveParticle = function () {
scratch_i = 0;
while (scratch_i <= SCRATCH_MAX_PARTICLE) {
if (this.particles["scratch_particle" + scratch_i] == undefined) {
return(undefined);
}
if ((this.particles["scratch_particle" + scratch_i].vx != 0) && (this.particles["scratch_particle" + scratch_i].vx != 0)) {
this.particles["scratch_particle" + scratch_i].vy = this.particles["scratch_particle" + scratch_i].vy + SCRATCH_GRAVITY;
this.particles["scratch_particle" + scratch_i].vx = this.particles["scratch_particle" + scratch_i].vx * SCRATCH_RESISTANCE;
this.particles["scratch_particle" + scratch_i].vy = this.particles["scratch_particle" + scratch_i].vy * SCRATCH_RESISTANCE;
if (Math.abs(this.particles["scratch_particle" + scratch_i].vx) <= 0.1) {
this.particles["scratch_particle" + scratch_i].vx = 0;
}
if (Math.abs(this.particles["scratch_particle" + scratch_i].vy) <= 0.1) {
this.particles["scratch_particle" + scratch_i].vy = 0;
}
this.particles["scratch_particle" + scratch_i]._x = this.particles["scratch_particle" + scratch_i]._x + this.particles["scratch_particle" + scratch_i].vx;
this.particles["scratch_particle" + scratch_i]._y = this.particles["scratch_particle" + scratch_i]._y + this.particles["scratch_particle" + scratch_i].vy;
}
scratch_i++;
}
};
runReveal = function () {
if (this.revealed == true) {
return(undefined);
}
this.createEmptyMovieClip("timer", this.getNextHighestDepth());
this.timer.onEnterFrame = function () {
SCRATCH_WIN_TIMING--;
if (SCRATCH_WIN_TIMING <= 0) {
if (this._parent.result._currentframe == 1) {
runWin();
delete this.onEnterFrame;
this.removeMovieClip();
return(undefined);
}
runLose();
delete this.onEnterFrame;
this.removeMovieClip();
return(undefined);
}
};
this.scratch_mask.onEnterFrame = function () {
this.fade.gotoAndStop(Math.min(400, this.fade._currentframe + SCRATCH_REVEAL_SPEED));
if (this.fade._currentframe >= 400) {
delete this.onEnterFrame;
delete this._parent.scratch_bmd;
delete this._parent.scratch_bmd2;
this._parent.result.setMask(null);
this._parent.surface.removeMovieClip();
this.removeMovieClip();
}
};
this.revealed = true;
};
fadeAll = function () {
this.result.onEnterFrame = function () {
if ((this._parent.coin._alpha - (SCRATCH_REVEAL_SPEED / 2)) <= 1) {
this._parent.coin._alpha = 0;
this._parent.coin.removeMovieClip();
scratch_i = 0;
while (scratch_i <= SCRATCH_MAX_PARTICLE) {
this._parent.particles["scratch_particle" + scratch_i].removeMovieClip();
scratch_i++;
}
delete this.onEnterFrame;
return(undefined);
}
scratch_i = 0;
while (scratch_i <= SCRATCH_MAX_PARTICLE) {
this._parent.particles["scratch_particle" + scratch_i]._alpha = this._parent.particles["scratch_particle" + scratch_i]._alpha - (SCRATCH_REVEAL_SPEED / 2);
scratch_i++;
}
this._parent.coin._alpha = this._parent.coin._alpha - (SCRATCH_REVEAL_SPEED / 2);
};
};