?
Solved

Automate current erase effect

Posted on 2010-01-12
2
Medium Priority
?
665 Views
Last Modified: 2013-11-11
Hey,

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.
this.createEmptyMovieClip('mask_mc',0); 
bg_mc.setMask(mask_mc);
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);
	}
	mask_mc.endFill();
}

// contor variable is used to hold if the mouse is pressed (contor is 1) or not (contor is 0)
this.onMouseDown=function(){
	drawCircle(mask_mc);
	contor=1;
}

// if the mouse is hold and moved then we draw a circle on the mask_mc
this.onMouseMove=this.onEnterFrame=function(){
	if (contor==1){
		drawCircle(mask_mc);
	}
}
this.onMouseUp=function(){
	contor=0;
}

Open in new window

EraseEffect.zip
0
Comment
Question by:mrsam
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 19

Accepted Solution

by:
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...
0
 

Author Comment

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

Thanks a lot for your help!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
Suggested Courses

762 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