Draw pixels

Code Actionscript 2.0

Frame action

createEmptyMovieClip("drawing", 1);
_root.bitmap = new flash.display.BitmapData(400, 400, true, 0xFF000000);
drawing.attachBitmap(_root.bitmap, 10, "auto", true);

onEnterFrame = function () {
pixel(_xmouse, _ymouse, 0xFFFFFF);
};
function pixel(px, py, c) {
_root.bitmap.setPixel(px, py, c);
}

Code Actionscript 3.0

addEventListener(Event.ENTER_FRAME, enterFrame); var bitmapdata = new BitmapData(400,400, true, 0xFF000000); var bitmap = new Bitmap(bitmapdata); this.addChild(bitmap); function enterFrame(e:Event) { pixel(mouseX, mouseY, 0xffffff); } function pixel(px:uint, py:uint, c:int) { bitmapdata.setPixel(px,py, c); }

Description

This "Starry Night" example is a drawing program that places unconnected dots on the canvas. The script draws a single pixel at the current mouse position xmouse, ymouse.

related to: Pixel

Download

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


Share