Forum Topic: making an eraser?

(83 views • 5 replies)

This topic is 1 page long.

<< < > >>
None

Mesmay

Reply To Post Reply & Quote

Posted at: 2/27/09 03:35 PM

Mesmay NEUTRAL LEVEL 06

Sign-Up: 01/09/08

Posts: 10

well, i have a little problem, and i assume you guys have the answer, you generally do :D

I want to make an eraser which follows the mouse automatically, which will be used to erase a layer of solid colour, not "all of it" when you rollover, just the bit you rollover.
If that makes any sense?
All help appreciated, thanks

oh and also- there will be an image underneath, so the eraser mustnt erase right through to the canvas.


Expressionless

matthewt

Reply To Post Reply & Quote

Posted at: 2/27/09 03:40 PM

matthewt NEUTRAL LEVEL 04

Sign-Up: 09/22/04

Posts: 24

Good luck in finding a program that helps you make the eraser. I've seen something like this before, online. I've been a webmaster for about 6 years now and I'd have to say that it's already been built. A good approach, for you, right now, is to do a focused keyword search at Google and visit as many web pages as you can. Maybe: erasing curser. There might be some tips on making this eraser, somewhere.


None

StaliN98

Reply To Post Reply & Quote

Posted at: 2/27/09 03:55 PM

StaliN98 LIGHT LEVEL 10

Sign-Up: 07/27/07

Posts: 690

How about have whatever is behind the layer to erase IN FRONT, but with a mask layer. Now, on the mask layer, have an empty movie clip. Call it "erase". Then put this on the main timeline. (This is AS2)

var lastx:Number = 0; // Last x mouse
var lasty:Number = 0; // Last y mouse
function onEnterFrame() {
if(Key.isDown(1)){ // If mouse is down
erase.lineStyle(16,0,100); // 16 so it is thick, colour doesn't matter so it is 0 (black), full alpha
erase.moveTo(lastx,lasty); // Move to last mouse position
erase.lineTo(_xmouse,_ymouse); // Draw a line to new position
}
lastx = _xmouse; // Update last x
lasty = _ymouse; // ... and y
}

None

StaliN98

Reply To Post Reply & Quote

Posted at: 2/27/09 03:58 PM

StaliN98 LIGHT LEVEL 10

Sign-Up: 07/27/07

Posts: 690

Forget that, lines don't register with masks it seems :S


None

Mesmay

Reply To Post Reply & Quote

Posted at: 2/27/09 04:06 PM

Mesmay NEUTRAL LEVEL 06

Sign-Up: 01/09/08

Posts: 10

At 2/27/09 03:58 PM, StaliN98 wrote: Forget that, lines don't register with masks it seems :S

yeah, i tried something like that already.
thanks for trying though :)


None

StaliN98

Reply To Post Reply & Quote

Posted at: 2/27/09 04:15 PM

StaliN98 LIGHT LEVEL 10

Sign-Up: 07/27/07

Posts: 690

Done, using bitmapdatas.
http://spamtheweb.com/ul/upload/270209/7 6363_erase.php
It basically makes a transparency enabled BitmapData of the image, and then you can draw rectangles with 0 alpha onto it to make it have holes.

import flash.display.*;
import flash.geom.*;
var lastx:Number = 0;
// Last x mouse
var lasty:Number = 0;
// Last y mouse

var maskBit:BitmapData = new BitmapData(640,480,true,0);
mask.attachBitmap(maskBit,0,"auto",false);

maskBit.draw(erase);

function onEnterFrame () {
	recta = new Rectangle(_xmouse - 16,_ymouse - 16,32,32);
	if (Key.isDown (1)) {
		maskBit.fillRect(recta,0);
	}
	lastx = _xmouse;
	// Update last x
	lasty = _ymouse;
	// ... and y
}

erase is the mc that holds the image you want to erase. the dimentions should be your stage size (of the bitmapdata). Mask is an mc above the one you want to be behind the erased image.


All times are Eastern Standard Time (GMT -5) | Current Time: 09:33 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!