Section 1
//MainTimeline (paintblot_fla.MainTimeline)
package paintblot_fla {
import flash.events.*;
import flash.text.*;
import flash.display.*;
import flash.utils.*;
import flash.filters.*;
import flash.geom.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.media.*;
import flash.net.*;
import flash.printing.*;
import flash.profiler.*;
import flash.sampler.*;
import flash.system.*;
import flash.ui.*;
import flash.xml.*;
public dynamic class MainTimeline extends MovieClip {
public var size:int;
public var brushtime:Timer;
public var ondown:Boolean;
public var faderadius:Number;
public var help2;
public var ig:int;
public var shadow:DropShadowFilter;
public var finalmat:BitmapData;
public var totalblack:int;
public var sub:BitmapData;
public var help;
public var ypos:Number;
public var mydotdist:Number;
public var offsetx:Number;
public var offsety:Number;
public var finalmat2:Bitmap;
public var bm:Bitmap;
public var size2:Number;
public var totalaverage:int;
public var incx:Number;
public var incy:Number;
public var mat:BitmapData;
public var alph:Number;
public var totalwhite:int;
public var minx:int;
public var miny:int;
public var dotdist:Number;
public var i;
public var bmd:BitmapData;
public var fade:Number;
public var fadesize:int;
public var bmv:Array;
public var glow:GlowFilter;
public var radius:Number;
public var maxx:int;
public var maxy:int;
public var ysq:Number;
public var lasty:int;
public var dist:Number;
public var lastx:int;
public var howmany:int;
public var mdx:int;
public var smallcircley:Array;
public var smallcirclex:Array;
public var mdy:int;
public var bigcircle:Array;
public var mat2:Bitmap;
public var underline:TextFormat;
public var xpos:Number;
public var xsq:Number;
public var subdown:BitmapData;
public var rect:Rectangle;
public var i2;
public var i3;
public var i4;
public var lastsub:int;
public var format:TextFormat;
public var nzjskdf:Sprite;
public function MainTimeline(){
addFrameScript(0, frame1, 1, frame2);
}
public function stopout(_arg1:Event):void{
ondown = false;
}
public function linkout(_arg1:Event):void{
_arg1.currentTarget.getChildAt(0).setTextFormat(format);
}
public function maketext(_arg1:String=""):TextField{
var str = _arg1;
var txt:TextField = new TextField();
var _local3 = txt;
with (_local3) {
antiAliasType = AntiAliasType.ADVANCED;
autoSize = TextFieldAutoSize.LEFT;
wordWrap = false;
multiline = true;
selectable = false;
defaultTextFormat = format;
text = str;
};
return (txt);
}
public function keyup(_arg1:KeyboardEvent):void{
if (_arg1.keyCode == 46){
finalmat.fillRect(new Rectangle(0, 0, finalmat.width, finalmat.height), 0);
} else {
if (_arg1.keyCode == 72){
if (contains(help)){
removeChild(help);
addChild(help2);
} else {
removeChild(help2);
addChild(help);
};
} else {
if ((((_arg1.keyCode == 48)) || ((_arg1.keyCode == 96)))){
alph = 1;
} else {
if ((((_arg1.keyCode >= 49)) && ((_arg1.keyCode <= 57)))){
alph = ((_arg1.keyCode - 48) / 10);
} else {
if ((((_arg1.keyCode >= 97)) && ((_arg1.keyCode <= 105)))){
alph = ((_arg1.keyCode - 95) / 10);
} else {
if (_arg1.keyCode == 38){
radius = (radius + 0.5);
} else {
if (_arg1.keyCode == 40){
radius = (radius - 0.5);
} else {
if (_arg1.keyCode == 37){
fade = (fade - 0.2);
} else {
if (_arg1.keyCode == 39){
fade = (fade + 0.2);
};
};
};
};
};
};
};
if (radius <= 0){
radius = 0.5;
};
if (fade < 0){
fade = 0;
};
changebrush();
};
};
}
public function brushtimecomplete(_arg1:TimerEvent):void{
brushclear();
}
public function paintline(_arg1:int, _arg2:int, _arg3:int, _arg4:int){
var _local5:int;
mdx = dif(_arg1, _arg3);
mdy = dif(_arg2, _arg4);
if (mdx > mdy){
_local5 = mdx;
} else {
_local5 = mdy;
};
incx = ((_arg3 - _arg1) / _local5);
incy = ((_arg4 - _arg2) / _local5);
mat.lock();
i = 0;
while (i < _local5) {
xpos = (_arg1 + (incx * i));
ypos = (_arg2 + (incy * i));
mydotdist = Math.sqrt((Math.pow(dif(xpos, lastx), 2) + Math.pow(dif(ypos, lasty), 2)));
if (mydotdist >= dotdist){
mat.copyPixels(bmd, rect, new Point((xpos - size2), (ypos - size2)), null, null, true);
lastx = xpos;
lasty = ypos;
};
i++;
};
mat.unlock();
}
public function brushclear(){
mat.fillRect(new Rectangle(((stage.stageWidth / 2) - (size / 2)), 0, size, size), 0);
brushtime.removeEventListener(TimerEvent.TIMER, brushtimecomplete);
}
function frame1(){
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
}
public function nogo(_arg1:Event):void{
stopbrush();
}
function frame2(){
stop();
radius = 2;
fade = 1.6;
alph = 1;
mat = new BitmapData(stage.stageWidth, stage.stageHeight, true, 0);
mat2 = new Bitmap(mat);
finalmat = new BitmapData(stage.stageWidth, stage.stageHeight, true, 0);
finalmat2 = new Bitmap(finalmat);
bigcircle = new Array();
smallcirclex = new Array();
smallcircley = new Array();
brushtime = new Timer(3000);
stage.addEventListener(MouseEvent.MOUSE_DOWN, go);
stage.addEventListener(Event.MOUSE_LEAVE, leaving);
nzjskdf = new Sprite();
addChild(finalmat2);
addChild(mat2);
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyup);
format = new TextFormat();
format.color = 0;
format.size = 15;
format.font = "Arial";
underline = new TextFormat();
underline.underline = true;
shadow = new DropShadowFilter();
shadow.distance = 0;
shadow.angle = 25;
shadow.strength = 1.2;
glow = new GlowFilter();
var _local2 = glow;
with (_local2) {
blurX = 12;
blurY = 12;
color = 0xFFFFFF;
};
help = maketext("press 'up' and 'down' to change brush sizes\npress 'left' and 'right' to change fuzziness\npress 'delete' to clear the board\npress 0-9 to change opacity (1 is 10%, 9 is 90%, 0 is 100%)\npress 'h' to disable this help message");
help.y = ((stage.stageHeight - help.height) - 4);
addChild(help);
help2 = maketext("'h' to show help");
help2.y = ((stage.stageHeight - help2.height) - 4);
help2.x = ((stage.stageWidth - help2.width) - 2);
changebrush();
}
public function stopclicks(_arg1):void{
_arg1.addEventListener(MouseEvent.MOUSE_OVER, stopover);
_arg1.addEventListener(MouseEvent.MOUSE_OUT, stopout);
}
public function stopbrush():void{
stage.addEventListener(MouseEvent.MOUSE_UP, nogo);
stage.removeEventListener(MouseEvent.MOUSE_MOVE, going);
var _local1:Rectangle = new Rectangle(minx, miny, (maxx - minx), (maxy - miny));
mat.colorTransform(_local1, new ColorTransform(1, 1, 1, alph));
finalmat.copyPixels(mat, _local1, new Point(minx, miny), null, null, true);
mat.fillRect(_local1, 0);
}
public function dif(_arg1:int, _arg2:int){
if (_arg1 > _arg2){
return ((_arg1 - _arg2));
};
return ((_arg2 - _arg1));
}
public function changebrush():void{
var _local1:int;
var _local2:int;
mat2.alpha = alph;
bmv = new Array();
size = (Math.ceil((radius * 2)) + 2);
if ((((radius > 1)) && ((fade > 0)))){
faderadius = ((radius * fade) * 0.7);
fadesize = Math.ceil((faderadius * 2));
size = (size + (faderadius * 2));
};
size2 = (size / 2);
dotdist = (radius * 0.3);
bmd = new BitmapData(size, size, true, 0);
sub = new BitmapData(size, size, true, 0);
rect = new Rectangle(0, 0, size, size);
i = 0;
while (i < size) {
offsety = dif(i, size2);
ysq = (offsety * offsety);
i2 = 0;
while (i2 < size) {
offsetx = dif(i2, size2);
dist = Math.sqrt((ysq + (offsetx * offsetx)));
if ((dist + 0.5) <= radius){
bmv[(i2 + (i * size))] = 1;
} else {
if ((dist - 0.5) >= radius){
bmv[(i2 + (i * size))] = 0;
} else {
bmv[(i2 + (i * size))] = (radius - (dist - 0.5));
};
};
bmd.setPixel32(i2, i, uint((((((0xFF * bmv[(i2 + (i * size))]) << 24) | (0 << 16)) | (0 << 8)) | 0)));
i2++;
};
i++;
};
if ((((fade > 0)) && (false))){
i = 0;
while (i < fadesize) {
offsety = dif(i, (fadesize / 2));
ysq = (offsety * offsety);
i2 = 0;
while (i2 < fadesize) {
offsetx = dif(i2, (fadesize / 2));
dist = Math.sqrt((ysq + (offsetx * offsetx)));
if (dist <= (fadesize / 2)){
smallcirclex.push(i2);
smallcircley.push(i);
};
i2++;
};
i++;
};
bmd.lock();
i = 0;
while (i < size) {
i2 = 0;
while (i2 < size) {
i3 = 0;
while (i3 < smallcirclex.length) {
_local2 = ((i - faderadius) + smallcircley[i3]);
if ((((_local2 >= 0)) && ((_local2 <= size)))){
_local1 = ((i2 - faderadius) + smallcirclex[i3]);
if ((((_local1 >= 0)) && ((_local1 <= size)))){
if (bmv[((size * _local2) + _local1)] != null){
totalblack = (totalblack + bmv[((size * _local2) + _local1)]);
};
};
};
i3++;
};
totalaverage = Math.ceil((((0xFF * bmv.length) / totalblack) / bmv.length));
bmd.setPixel32(i2, i, uint(((((totalaverage << 24) | (0 << 16)) | (0 << 8)) | 0)));
bmv[(i2 + (i * size))] = totalaverage;
totalblack = 0;
totalwhite = 0;
i2++;
};
i++;
};
bmd.unlock();
};
if (radius > 0.5){
bmd.applyFilter(bmd, new Rectangle(0, 0, size, size), new Point(0, 0), new BlurFilter(faderadius, faderadius, 3));
};
i = 0;
while (i < (size * size)) {
if (Math.ceil((i / size)) != (i / size)){
sub.setPixel32((i - (Math.floor((i / size)) * size)), Math.floor((i / size)), uint(((((Math.floor((((bmv[i] + bmv[(i - 1)]) / 2) * 0xFF)) << 24) | (0 << 16)) | (0 << 8)) | 0)));
} else {
sub.setPixel32((i - (Math.floor((i / size)) * size)), Math.floor((i / size)), uint((((((((bmv[i] + 0xFF) / 2) * 0xFF) << 24) | (0xFF << 16)) | (0 << 8)) | 0)));
};
i++;
};
sub.applyFilter(sub, new Rectangle(0, 0, size, size), new Point(0, 0), new BlurFilter(faderadius, faderadius));
if (stage.hasEventListener(MouseEvent.MOUSE_MOVE) == false){
if (brushtime.running){
brushclear();
brushtime.stop();
brushtime.reset();
};
mat.copyPixels(bmd, rect, new Point(((stage.stageWidth / 2) - (size / 2)), 0), null, null, true);
brushtime.addEventListener(TimerEvent.TIMER, brushtimecomplete);
brushtime.start();
};
}
public function leaving(_arg1:Event):void{
stopbrush();
}
public function linkover(_arg1:Event):void{
_arg1.currentTarget.getChildAt(0).setTextFormat(underline);
}
public function stopover(_arg1:Event):void{
ondown = true;
}
public function go(_arg1:Event){
if (ondown == false){
if (brushtime.running){
brushclear();
brushtime.stop();
brushtime.reset();
};
stage.addEventListener(MouseEvent.MOUSE_UP, nogo);
stage.addEventListener(MouseEvent.MOUSE_MOVE, going);
mat.copyPixels(bmd, rect, new Point((mouseX - size2), (mouseY - size2)), null, null, true);
minx = (mouseX - size2);
miny = (mouseY - size2);
maxx = (mouseX + size2);
maxy = (mouseY + size2);
lastx = mouseX;
lasty = mouseY;
};
}
public function makelink(_arg1:String=""):Object{
var _local2:Object = {spr:new Sprite(), txt:maketext(_arg1)};
_local2.spr.addChild(_local2.txt);
_local2.spr.addEventListener(MouseEvent.MOUSE_OVER, linkover);
_local2.spr.addEventListener(MouseEvent.MOUSE_OUT, linkout);
return (_local2);
}
public function going(_arg1:Event){
paintline(lastx, lasty, mouseX, mouseY);
if ((mouseX - size2) < minx){
minx = (mouseX - size2);
} else {
if ((mouseX + size2) > maxx){
maxx = (mouseX + size2);
};
};
if ((mouseY - size2) < miny){
miny = (mouseY - size2);
} else {
if ((mouseY + size2) > maxy){
maxy = (mouseY + size2);
};
};
}
}
}//package paintblot_fla