Ok some of you prolly remember the mystify screensaver from windows? was in like 95 or something well here is the code to make it in flash
the last section of if&else statements simply define the color - now i know this could prolly have been done better by having it pull the colors from an array but at the time i was still learning about arrays in actionscript so......Code:function drawQuad(clip) { path = _root.page4[clip]; path.lineStyle(3, mycolor, 50); path.moveTo(x[0], y[0]); path.curveTo(x[1], y[1], x[2], y[2]); path.curveTo(x[3], y[3], x[0], y[0]); } // Define screen extents for later use... Stage.scaleMode = "exactFit"; middleX = Stage.width/2; middleY = Stage.height/2; Stage.scaleMode = "noScale"; /* create clip... */ _root.createEmptyMovieClip("page4", 100); page4._x = middleX; page4._y = middleY; /* Initialize points... */ width = 100; height = 100; x = new Array(); y = new Array(); sX = new Array(); sY = new Array(); x[0] = 0; y[0] = 0; x[1] = 0; y[1] = -height; x[2] = -width; y[2] = -height; x[3] = -width; y[3] = 0; for (i=0; i<4; i++) { sX[i] = Math.random()*3+2; sY[i] = Math.random()*3+2; } j = 0; page4.onEnterFrame = function() { j++; for (i=0; i<4; i++) { x[i] += sX[i]; y[i] += sY[i]; if (Math.abs(x[i])>width) { sX[i] = -sX[i]; } if (Math.abs(y[i])>height) { sY[i] = -sY[i]; } } page4.createEmptyMovieClip("quad"+j, j); drawQuad("quad"+j); if (j>24) { j = 0; } }; mycolor = 0xffffff onMouseDown = function () { mycolor2 = (Math.random()*100) if (mycolor2 < 10){ mycolor = 0x959CCE; } else if (mycolor2 < 15){ mycolor = 0x80DFD8; } else if (mycolor2 < 20){ mycolor = 0xCAF06F; } else if (mycolor2 < 25){ mycolor = 0x98C7C2; } else if (mycolor2 < 30){ mycolor = 0xF4FB68; } else if (mycolor2 < 35){ mycolor = 0x63E9FC; } else if (mycolor2 < 40){ mycolor = 0x82ED72; } else if (mycolor2 < 45){ mycolor = 0x84D0DB; } else if (mycolor2 < 50){ mycolor = 0xF16DE1; } else if (mycolor2 < 55){ mycolor = 0x98C7C2; } else if (mycolor2 < 60){ mycolor = 0xD28CA4; } else if (mycolor2 < 65){ mycolor = 0x98C1C7; } else if (mycolor2 < 70){ mycolor = 0xEA75EA; } else if (mycolor2 < 75){ mycolor = 0x8DD19E; } else if (mycolor2 < 80){ mycolor = 0xA5A4BB; } else if (mycolor2 < 85){ mycolor = 0xC798AE; } else if (mycolor2 < 90){ mycolor = 0xC4D788; } else if (mycolor2 < 95){ mycolor = 0x9FC699; } else if (mycolor2 < 100){ mycolor = 0xffffff; } else { mycolor = 0xF32559; } }
but could be easilt changed to something like
and so on then to have it choose a color from the array you could useCode:colorsarray = new Array() colorsarray[0] = "0xF32559" colorsarray[1] = "0xffffff"
which would be a hell of alot easierCode:onMouseDown = function () { mycolor2 = (Math.random()*100) mycolor = colorsarray[mycolor2] };![]()
v_Ln


Reply With Quote