Ribbon

Code Actionscript 2.0

Frame action

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; }

Description

This is a variation of a simple drawing program. One way of avoiding the standardized lines is by programming custom line-shapes. A ribbon is composed of areas with varying opacity. The variables last_px and last_py store the last position of the mouse cursor. These coordinates are used, to connect the current position with the one from the last step.

Download

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


Share