Skip to main content
April 7, 2006
Question

Make my cursor move slower

  • April 7, 2006
  • 9 replies
  • 479 views
I have a flash file that when you move the cursor the mask is revealed and you see the picture below. My problem is I want to slow down the cursor a bit so that if you mover your cursor too fast you don't see single boxes. I want to see one smooth line.

Thanks;
Raymond
This topic has been closed for replies.

9 replies

April 25, 2006
Does anyone have any better Ideas?
April 20, 2006
I believe I did something similar. The problem is when you move the mouse too fast the x,y skips so I would end up with a bunch of dots across the screen. I am looking to calculate the coordinate’s in-between the dots.

Givens:
current x,y
previous x,y
thickness of pen = 10px (this of it like an eraser it's thickness is 10px)

Flow:
If current x,y is greater the 5 pixels (which is half the radius of the 10px pen) from previous x,y then calculate the distance and subtract the numbers take that number x and divide that by 5 (round off the numbers to be hole numbers). What ever that number is us it in a for loop add 5 to the previous x,y until the loop is completed. Everything is put into an array which is then played back moving the pen. So really the array moves the pen not the mouse. I would have to do 2 checks. one is to see if the mouse has moved to negative numbers rather then positive numbers (there may be a easer way then using a if statement for this) and I need to check if the new calculations go beyond the current x,y if so delete the last calculation.

e.g.
For now just using X
CurrentX = 200 (get from current Mouse position)
PreviousX = 180 (get from Array)
Pen = 10
All x,y are added to array if x,y is larger then the radius of 5 (half the diameter of Pen) then calculate new positions.

Check if 200 is 5px greater the 180

200-180= 20

20 is greater then 5, divide by 5

Calculate loop: 20/5 = 4

NewPreviousX = PreviousX(remember PreviousX =180)
loop 4 times: NewPreviousX= (NewPreviousX+5)
Check if NewPreviouseX is larger then CurrentX if so delete it.
Add each new number to existing array

This is what I am thinking in order to get it to work. I may be missing a step or two. My problem is I know enough to get myself into trouble, I don't know what all the cool math functions can do or even all of the operations signs do and if there is something that might help with the calculations.

Let me know if I am on the right track.

Thanks;
Raymond
Inspiring
April 19, 2006
Sorry. Missed this – didn't mean to abandon you.

There are many ways to implement this, but first read the entries in the help files for moveTo and lineTo. These are methods of the MovieClip class. There will also be some other related entries listed at the bottom of those two that you should check out as well.

I'm not sure you need to go as fancy as abeall has suggested. I think an easier version might be like this. You already know how to get the x,y of the mouse, right?

So you get the x,y and moveTo that.
Set the line to the style you want.
In the next frame (or onMouseMove) you get the new x,y
lineTo that
Repeat

You might just want to try some line drawing on its own to get the hang of it.
April 18, 2006
Is there anyone that could help me with the suggestion that "abeall" made using lineTo or curveTo?

Thanks
Raymond
April 13, 2006
How would I go about this? You say lineTo or curveTo but I could not get it to work. I tried to put my mouse movements into an Array. I was going to try to write code that would check the x,y and if the space is too far add additional points in between I would base it on the thickness of the line. So if the line is 10px I would check to make sure that the spacing is no more then 5px if it is greater add additional points every five pixels.

I would think that what I am trying to do is a bit more complicated.

Thanks;
Raymond
April 7, 2006
Here's the problem: the mouse input is incremental and if you move fast takes large jumps, even onMouseMove(which i recomend you use instead of onEnterFrame), so what you are going to have to do is when the mouse moves, draw from *between* the previous position and the current position.

lineTo or curveTo would provide an easy way to do this, but prior to Flash 8 it can only have a maximum stroke width of 10px.
April 7, 2006
Rothtrock
I'm guessing by his statement "so that if you move your cursor too fast you don't see single boxes" that he's using duplicateMovieClip in onMouseMove or onEnterFrame to do that scratch & win type effect, and so if the mouse movement increment is bigger than the duplicated clip you it doesn't look like a line, but rather punches.

Just my guess, anyway, since he didn't provide enough information.
April 7, 2006
Sorry guys I was not sure how to explain the issue. abeall is correct, I am using the onEnterFrame and the Draw API to make a box (I would like a circle but I can't seem to get that to work but I digress) As you move the cursor across the screen you get a punch hole effect which is what I would like to avoid. I do not want to create a creature that would reach out and grab your hand although that would be a very cool effect. =) I would like to slow down the mask so I would not get the punch hole effect.

Here are my samples:
Scrach & Win
Scrach & Win Fla file

What I was thinking of doing was to add a timer and for every time you moved your mouse it would delay the mask.

Thank you in advance
Raymond
Inspiring
April 7, 2006
You can't slow down the mouse. How would that work? A big mechanical claw that jumped out of the user's computer and grabbed their hand? Scary! (but I kind of like it.)

Anyways, what you can control is the speed of the reveal. Without know all your code and the effect you are going for it is difficult to say. But I imagine you are reading the position of the mouse and moving in that direction? You can add some kind of code that checks how far the reveal would move and if it is above some limit you would only move part of the way. Understand?
April 7, 2006
You can't.

It's not really clear what your problem is, but by my best guess at what you talking about maybe using lineTo or curveTo will be of some help.