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

Random-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 = random(400); return (py); }

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 = int(Math.random()*400); return (py); }

Infos

Dieses Skript zeichnet eine wilde Zickzack-Kurve. Die Funktion random(400) (Math.random(400) in Actionscript 3) ergibt eine Zufallszahl zwischen 0 und 400.

Download

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


Share