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

Absolut-Funktion

Code Actionscript 2.0

Frame-Aktion

// initialize drawing createEmptyMovieClip("drawing", 1); drawing.lineStyle(0, 0x000000, 100); drawing.moveTo(0, 200); // go from left to right // and calculate function values for (px = 0; px < 400; px = px + 1) { py = graph(px); drawing.lineTo(px, py); } function graph(px) { py = 200 * Math.abs(sine(2 * px)); return (py); } function sine(x) { // sine conversion for values between 0 und 360° s = Math.sin(x * 2 * Math.PI / 360); return s; }

Code Actionscript 3.0

// initialize drawing var drawing:MovieClip = new MovieClip(); drawing.graphics.lineStyle(0, 0x000000, 1); drawing.graphics.moveTo(0, 0); this.addChild(drawing); // go from left to right // and calculate function values for (var px = 0; px < 400; px = px + 1) { var py = graph(px); drawing.graphics.lineTo(px, py); } function graph(px:int) { py = 200 * Math.abs(sinus(2 * px)); return (py); } function sinus(x:int) { // sine conversion for values between 0 und 360° var s = Math.sin(x * 2 * Math.PI/ 360); return s; }

Infos

Dieses Skript zeichnet hängende Bögen. Die Absolut-Funktion Math.abs verwandelt negative Zahlen in positive, und lässt positive Zahlen unverändert.

Download

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


Share