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

Band

Code Actionscript 2.0

Frame-Aktion

createEmptyMovieClip("drawing", 1);
drawing.lineStyle(0, 0x000000, 0);
last_px = _xmouse;
last_py = _ymouse;

onMouseDown = function () {
mousepressed = 1;
};
onMouseUp = function () {
mousepressed = 0;
};
onEnterFrame = function () {
px = _xmouse;
py = _ymouse;
if (mousepressed == 1) {
drawing.beginFill(0x000000, random(80));
drawing.moveTo(last_px - 10, last_py - 20);
drawing.lineTo(px - 10, py - 20);
drawing.lineTo(px + 10, py + 20);
drawing.lineTo(last_px + 10, last_py + 20);
drawing.endFill();
}
last_px = px;
last_py = py;
};

Code Actionscript 3.0

addEventListener(Event.ENTER_FRAME, enterFrame); stage.addEventListener(MouseEvent.MOUSE_DOWN, press); stage.addEventListener(MouseEvent.MOUSE_UP, release); var drawing:MovieClip = new MovieClip(); drawing.graphics.lineStyle(0, 0x000000, 0); this.addChild(drawing); var last_px=0; var last_py=0; var mousepressed=0; function press(e:MouseEvent) { mousepressed = 1; } function release(e:MouseEvent) { mousepressed = 0; } function enterFrame(e:Event) { var px = mouseX; var py = mouseY; if (mousepressed == 1) { drawing.graphics.beginFill(0x000000, Math.random()*0.8); drawing.graphics.moveTo(last_px - 10, last_py - 20); drawing.graphics.lineTo(px - 10, py - 20); drawing.graphics.lineTo(px + 10, py + 20); drawing.graphics.lineTo(last_px + 10, last_py + 20); drawing.graphics.endFill(); } last_px = px; last_py = py; }

Infos

Das Beispiel zeigt eine weiterführende Variante eines Zeichenprogramms. Eine Möglichkeit von den standardisierten Liniendarstellungen wegzukommen besteht darin, sich eine eigene Linienform zu programmieren. Mithilfe von Flächen wird ein Band gezeichnet, dessen Segmente sich in der Deckkraft unterscheiden. Auf solche Weise können individuelle Zeichenwerkzeuge programmiert werden. Die Variabeln last_px und last_py speichern die letzte Position des Mauszeigers. Diese Angaben werden benötigt um im nächsten Programmdurchlauf die aktuelle Position mit der vorangegangenen zu verbinden.

Download

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


Share