The current existing code involves interaction with keypad (such as controlling the rotation speed, adding more tiles to the kaleidoscope, toggle/flip tiles, etc).
import flash.display.BitmapData;
import flash.geom.Matrix;
_quality = "BEST";
var hsize = 500;
var vsize = 500;
var diag:Number = Math.sqrt(2*hsize*hsize)*0.62;
var map:BitmapData = new BitmapData(hsize, vsize, true, 0x00000000);
var mapHolder:MovieClip = createEmptyMovieClip("mapHolder", 1);
var code:MovieClip;
mapHolder.attachBitmap(map, 0);
var image:BitmapData = BitmapData.loadBitmap("image");
var stampImage:BitmapData = new BitmapData(image.width, image.height, false);
stampImage.draw(image, new Matrix(0.5, 0, 0, 0.5, 0, 0), null, "normal", null, true);
stampImage.draw(image, new Matrix(-0.5, 0, 0, 0.5, image.width, 0), null, "normal", null, true);
stampImage.draw(image, new Matrix(0.5, 0, 0, -0.5, 0, image.height), null, "normal", null, true);
stampImage.draw(image, new Matrix(-0.5, 0, 0, -0.5, image.width, image.height), null, "normal", null, true);
image.dispose();
var rotate1:Boolean = false;
var rotate2:Boolean = false;
var rotate3:Boolean = false;
var flip:Boolean = true;
var singleview:Boolean = true;
var slice:MovieClip = createEmptyMovieClip("slice", 0);
slice._visible = false;
var slices:Number = 12;
var angle = Math.PI/slices;
var nudge = 0.009;
var rotspeed1 = 0.007;
var rotspeed2 = -0.003;
var rotspeed3 = -0.005;
var sclfact = 0;
var rot:Number = 0;
var r:Number = 0;
var r2:Number = 0;
var sh1:Number = 0;
var sh2:Number = 0;
var scl:Number = 1;
var m:Matrix = new Matrix();
Key.addListener(this);
function onKeyDown() {
switch (Key.getCode()) {
case Key.UP :
scl *= 1.03;
break;
case Key.DOWN :
scl *= 0.96;
break;
case Key.LEFT :
r -= 0.01;
break;
case Key.RIGHT :
r += 0.01;
break;
case 187 :
//+
slices += 2;
angle = Math.PI/slices;
break;
case 189 :
//-
if (slices>4) {
slices -= 2;
angle = Math.PI/slices;
}
break;
case 49 :
//1
rotate1 = !rotate1;
break;
case 50 :
//2
rotate2 = !rotate2;
break;
case 51 :
//3
rotate3 = !rotate3;
break;
case 52 :
//4
flip = !flip;
break;
case 53 :
//5
sh1 += 0.04;
break;
case 54 :
//6
sh1 -= 0.04;
break;
case 55 :
//7
sh2 += 0.04;
break;
case 56 :
//8
sh2 -= 0.04;
break;
case 78 :
//n
sclfact += 0.01;
break;
case 77 :
//m
sclfact -= 0.01;
break;
case 48 :
sclfact = 0;
break;
case 81 :
//q
rotspeed1 += 0.001;
break;
case 87 :
//w
rotspeed1 -= 0.001;
break;
case 65 :
//a
rotspeed2 += 0.001;
break;
case 89 :
//q
rotspeed3 += 0.001;
break;
case 88 :
//w
rotspeed3 -= 0.001;
break;
case 69 :
rotspeed1 = 0;
break;
case 68 :
rotspeed2 = 0;
break;
case 67 :
rotspeed3 = 0;
break;
case 83 :
//s
rotspeed2 -= 0.001;
break;
}
}
function onEnterFrame() {
if (rotate1) {
r += rotspeed1;
}
if (rotate2) {
r2 -= rotspeed2;
}
if (rotate3) {
rot += rotspeed3;
}
for (var i = 0; i
No comments:
Post a Comment