Section 1
//MainTimeline (test_AS3_fla.MainTimeline)
package test_AS3_fla {
import flash.events.*;
import flash.display.*;
import flash.filters.*;
public dynamic class MainTimeline extends MovieClip {
public var divr;
public var siz;
public var pcol;
public var keys;
public var scw;
public var sch;
public var bma:Array;
public var bmd:BitmapData;
public var bmp:Bitmap;
public var mouse;
public function MainTimeline(){
addFrameScript(0, frame1);
}
public function MouseUp(_arg1:MouseEvent){
mouse = false;
trace(bma.length);
}
function frame1(){
mouse = false;
keys = [];
stage.addEventListener(Event.ENTER_FRAME, Main);
stage.addEventListener(MouseEvent.MOUSE_DOWN, MouseDown);
stage.addEventListener(MouseEvent.MOUSE_UP, MouseUp);
stage.addEventListener(MouseEvent.MOUSE_WHEEL, MouseWheel);
stage.addEventListener(KeyboardEvent.KEY_DOWN, KeyDown);
stage.addEventListener(KeyboardEvent.KEY_UP, KeyUp);
scw = 550;
sch = 400;
divr = 2;
siz = 5;
bmd = new BitmapData((scw / divr), (sch / divr), false, 0);
bmp = new Bitmap(bmd);
addChild(bmp);
bmp.width = scw;
bmp.height = sch;
bma = new Array();
pcol = 13311;
}
public function KeyDown(_arg1:KeyboardEvent){
keys[_arg1.keyCode] = true;
}
public function rem(_arg1, _arg2, _arg3){
var _local4:*;
var _local5:*;
_local4 = -(_arg3);
while (_local4 < _arg3) {
_local5 = -(_arg3);
while (_local5 < _arg3) {
bmd.setPixel((_local5 + _arg1), (_local4 + _arg2), 0);
_local5++;
};
_local4++;
};
}
public function KeyUp(_arg1:KeyboardEvent){
keys[_arg1.keyCode] = false;
}
public function updateP(_arg1, _arg2){
if (((((((_arg2 + 1) >= (sch / divr))) || (((_arg1 + 1) >= (scw / divr))))) || (((_arg1 - 1) < 0)))){
return ([_arg1, _arg2]);
};
if (bmd.getPixel(_arg1, (_arg2 + 1)) == 0){
bmd.setPixel(_arg1, (_arg2 + 1), pcol);
bmd.setPixel(_arg1, _arg2, 0);
return ([_arg1, (_arg2 + 1)]);
};
if ((((bmd.getPixel((_arg1 + 1), _arg2) == pcol)) && ((bmd.getPixel((_arg1 - 1), _arg2) == 0)))){
bmd.setPixel((_arg1 - 1), _arg2, pcol);
bmd.setPixel(_arg1, _arg2, 0);
return ([(_arg1 - 1), _arg2]);
};
if ((((bmd.getPixel((_arg1 - 1), _arg2) == pcol)) && ((bmd.getPixel((_arg1 + 1), _arg2) == 0)))){
bmd.setPixel((_arg1 + 1), _arg2, pcol);
bmd.setPixel(_arg1, _arg2, 0);
return ([(_arg1 + 1), _arg2]);
};
if (bmd.getPixel((_arg1 + 1), (_arg2 + 1)) == 0){
bmd.setPixel((_arg1 + 1), (_arg2 + 1), pcol);
bmd.setPixel(_arg1, _arg2, 0);
return ([(_arg1 + 1), (_arg2 + 1)]);
};
if (bmd.getPixel((_arg1 - 1), (_arg2 + 1)) == 0){
bmd.setPixel((_arg1 - 1), (_arg2 + 1), pcol);
bmd.setPixel(_arg1, _arg2, 0);
return ([(_arg1 - 1), (_arg2 + 1)]);
};
return ([_arg1, _arg2]);
}
public function MouseDown(_arg1:MouseEvent){
mouse = true;
}
public function createG(_arg1, _arg2, _arg3){
var _local4:*;
var _local5:*;
var _local6:*;
var _local7:*;
var _local8:*;
_local7 = -(_arg3);
while (_local7 < _arg3) {
_local8 = -(_arg3);
while (_local8 < _arg3) {
_local4 = ((_local8 + _arg1) - _arg1);
_local5 = ((_local7 + _arg2) - _arg2);
_local6 = Math.sqrt(((_local4 * _local4) + (_local5 * _local5)));
if (_local6 < _arg3){
bmd.setPixel(((mouseX / divr) + _local8), ((mouseY / divr) + _local7), 0x993300);
};
_local8++;
};
_local7++;
};
}
public function createP(_arg1, _arg2, _arg3){
var _local4:*;
var _local5:*;
if (_arg3 == 1){
bma.push([_arg1, _arg2]);
bmd.setPixel(_arg1, _arg2, pcol);
} else {
_local4 = -(_arg3);
while (_local4 < _arg3) {
_local5 = -(_arg3);
while (_local5 < _arg3) {
bma.push([(_local5 + _arg1), (_local4 + _arg2)]);
bmd.setPixel((_local5 + _arg1), (_local4 + _arg2), pcol);
_local5++;
};
_local4++;
};
};
}
public function MouseWheel(_arg1:MouseEvent){
siz = (siz + (_arg1.delta / 3));
}
public function Main(_arg1:Event){
var _local2:*;
var _local3:*;
var _local4:*;
var _local5:*;
var _local6:*;
var _local7:*;
var _local8:*;
var _local9:*;
var _local10:BlurFilter;
var _local11:*;
_local2 = [];
_local3 = 0;
while (_local3 < bma.length) {
_local5 = bma[_local3];
bma[_local3] = updateP(_local5[0], _local5[1]);
_local3++;
};
_local4 = (bma.length - 1);
while (_local4 >= 0) {
_local6 = bma[_local4];
if (((mouse) && (keys[32]))){
_local7 = ((mouseX / divr) - _local6[0]);
_local8 = ((mouseY / divr) - _local6[1]);
_local9 = Math.sqrt(((_local7 * _local7) + (_local8 * _local8)));
if (_local9 < 5){
bmd.setPixel(_local6[0], _local6[1], 0);
bma.splice(_local4, 1);
};
};
_local4--;
};
if (keys[38]){
bmp.filters = [];
} else {
if (keys[40]){
if (bmp.filters.length == 0){
_local10 = new BlurFilter(4, 4, 30);
_local11 = [_local10];
bmp.filters = _local11;
};
};
};
if (((mouse) && (keys[17]))){
createG((mouseX / divr), (mouseY / divr), siz);
} else {
if (((mouse) && (keys[16]))){
bmd.setPixel((mouseX / divr), (mouseY / divr), 0);
} else {
if (((mouse) && (!(keys[32])))){
createP(Math.floor((mouseX / divr)), Math.floor((mouseY / divr)), 2);
};
};
};
}
}
}//package test_AS3_fla