NEU: Alle Visual Codes als Code Snippets für Flash CS5:
jetzt hier downloaden .

Sinusraster mit Lücken

Code Actionscript 2.0

Frame-Aktion

i = 1;
for (gy = 0; gy <= 8; gy = gy + 1) {
for (gx = 0; gx <= 8; gx = gx + 1) {
i = i + 1;
square0.duplicateMovieClip("square" + i, i);
_root["square" + i]._x = gx * 50;
_root["square" + i]._y = gy * 50;
_root["square" + i]._xscale = stretch(sine(gx * 22), 60, 30);
_root["square" + i]._yscale = stretch(sine(gx * 22), 60, 30);
if ((i % 2) == 0) {
// hide one out of two
_root["square" + i]._alpha = 0;
}
}
}
square0._visible = 0;
function sine(x) {
// sine conversion for values 0 - 360°
s = Math.sin(x * 2 * Math.PI / 360);
return s;
}
function stretch(value, center, amplitude) {
// scales and shifts value
st = int(value * amplitude + center);
return st;
}

Code Actionscript 3.0

var Squares:Array = new Array(); var i = 1; for (var gx = 0; gx <= 8; gx = gx + 1) { for (var gy = 0; gy <= 8; gy = gy + 1) { i = i+1; //important: square has to be exported for actionscript //go to "linkage" in library menu Squares[i] = new squareObject(); Squares[i].x = gx * 50; Squares[i].y = gy * 50; Squares[i].scaleX = stretch(sine(gx * 22), 60, 30)/100; Squares[i].scaleY = stretch(sine(gx * 22), 60, 30)/100; addChild(Squares[i]); if ((i % 2) == 0) { // hide one out of two Squares[i].alpha = 0; } } } square0.visible = false; function sine(x) { // sine between 0 und 360° var s = Math.sin(x * 2 * Math.PI / 360); return s; } function stretch(value, center, amplitude) { // scales and shifts value var st = int(value * amplitude + center); return st; }

Infos

Ein Grundelement wird auf einem 8x8 Raster angeordnet, dabei wird jedes zweite ausgeblendet. Die jeweilige Grösse der Quadrate wird durch eine Sinusfunktion bestimmt. Die Funktionen sine und stretch dienen der besseren Lesbarkeit. Die Funktion sine rechnet Winkel von Grad ins Bogenmass um. Die Funktion stretch skaliert und verschiebt die Sinuswerte, die zwischen -1 und 1 liegen.

verwandt mit:

Download

Right click: Flashfile AS 2.0 | Flashfile AS 3.0 | SWF-File


Share