Automate current erase effect

Posted on 2010-01-12
Medium Priority
Last Modified: 2013-11-11

I currently got an erase effect where you "scratch" off a top layer and and have a layer underneath. This is working fine. You move the mouse over the mask, hold down the button and it will erase and show whats underneath.

What im looking to do is, set a timer like:
eraseTimer = setInterval(automateErase, 5000);
The thought is, if the user hasn't erased anything within five seconds, an automated erase will start. (could be a up and down/side-to-side movement, until everything is "erased")

Any thoughts?
Ive attached the code and file - if anyone wants to look at that.
var contor:Number=0;

// function drawCircle draws a circle on mask_mc MovieClip of radius r and having center to mouse coordinates
function drawCircle(mask_mc:MovieClip):Void{
	var r:Number = 15;
	var xcenter:Number = _xmouse;
	var ycenter:Number = _ymouse;
	var A:Number = Math.tan(22.5 * Math.PI/180);
	var endx:Number;
	var endy:Number;
	var cx:Number;
	var cy:Number;
	mask_mc.beginFill(0x000000, 100);
	mask_mc.moveTo(xcenter+r, ycenter);
	for (var angle:Number = Math.PI/4; angle<=2*Math.PI; angle += Math.PI/4) {
	   xend = r*Math.cos(angle);
	   yend = r*Math.sin(angle);
	   xbegin =xend + r* A *Math.cos((angle-Math.PI/2));
	   ybegin =yend + r* A *Math.sin((angle-Math.PI/2));
	   mask_mc.curveTo(xbegin+xcenter, ybegin+ycenter, xend+xcenter, yend+ycenter);

// contor variable is used to hold if the mouse is pressed (contor is 1) or not (contor is 0)

// if the mouse is hold and moved then we draw a circle on the mask_mc
	if (contor==1){

Open in new window

Question by:mrsam
LVL 19

Accepted Solution

moagrius earned 2000 total points
ID: 26299441
if you want to keep the same effect, just run a function very similar to drawCircle on enterFrame (or setInterval), and instead of _xmouse and _ymouse, just use two incrementing numbers.  if you want up down, run _destY up from 0 until it hits Stage.height, then reset it to 0 and _destX += 15...  when _destX is >= Stage.width, kill the enterframe/interval...  just swap that logic for side to side erasure...

Author Comment

ID: 26535128
Hmm thought I accepted this a long time ago :/

Thanks a lot for your help!

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
Suggested Courses
Course of the Month7 days, 23 hours left to enroll

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question