all groups > flash actionscript > february 2006 >
You're in the

flash actionscript

group:

Line follow cursor


Line follow cursor twistedpancreas
2/26/2006 11:01:36 PM
flash actionscript:
I'm looking at simulating a computer's mouse in Flash, and I'd like the cord to
follow the mouse around as it moves around the screen. Is there some way to do
it, so that it looks natural (not just a straight line following the mouse)?

Thanks in advance.
Re: Line follow cursor tralfaz
2/26/2006 11:03:06 PM
[quoted text, click to view]

Can you use a more simplified effect? You can use moveTo and lineTo
just to make the wire curve to the mouse. It's not as cool looking
but a lot easier to manage. It could be improved with a second curve
into the head of the mouse.
http://www.kompanionkare.net/flash/curveLine.html
tralfaz

Re: Line follow cursor jdh239
2/27/2006 12:00:00 AM
Again, the button is an anchor. Drag it to wherever you want the line to start
(It is a very tiny dot on the stage--easy to miss if you aren't looking for
it). As far as being on top of everything, I don't know what to say there--I
would try moving it down layers to see if that makes a difference. For the
time being I will keep the source available for download. If anyone can help
this guy out I would appreciate it. I don't really understand the code much
myself--I just happened to have a copy of it.
Re: Line follow cursor jdh239
2/27/2006 1:38:44 AM
This is as close as I can get. Feel free to download the source code. Don't
ask me the logic behind it, because I don't know. You will just have to mess
around with it to get it the way you want.

There is a button, which is the anchor (move it to wherever you want the
string to start). There is a movie clip too, but it doesn't really matter
where it is (has some actionscript associated with it), and then there is a
little actionscript on the frame itself.

http://www.emailden.com/download/

line.fla
line.swf

Please let me know after you download it as I would like to disable the
download after it is complete.

Re: Line follow cursor twistedpancreas
2/27/2006 2:40:58 AM
wow that looks like what i'm exactly after!!!

thanks i'll check it out!!!

Re: Line follow cursor twistedpancreas
2/27/2006 4:15:00 AM
hmm a few problems with that file is that the centre of the line likes to start
from the top left hand corner, it also likes to be on top of all graphics.

So if you could help me out there that would be much appreciated, or if any
one else has a solution to my problem
Re: Line follow cursor tralfaz
2/27/2006 8:14:49 PM
[quoted text, click to view]

Sorry.. I got ahold of the wrong file for the zip. Use this one..
http://www.kompanionkare.net/flash/curveLine2.html
tralfaz

Re: Line follow cursor twistedpancreas
2/28/2006 3:58:27 AM
that's exactly what i'm after tralfaz, but you're fla file is different to the
swf shown on you're site.

i tried to understand the code but it's a bit advanced for me.

any chance of checking out the fla file for you're swf file?

thanks once again guys
Re: Line follow cursor twistedpancreas
2/28/2006 11:47:44 PM
Re: Line follow cursor twistedpancreas
3/2/2006 12:14:15 AM
ok what i would like to see happen is if the mouse moves to a certain x,y
co-ordinate, then it would jump to another frame in the timeline and play.

is this possible if the code for is:

_root.mid_mc._visible = false;
_root.mouse_mc.mouse_tip_mc._visible = false;
_root.mouse_mc.swapDepths(10); // higher in Z than the line drawing to hide
the wire

function initialize()
{
this.createEmptyMovieClip("mc", 1);
}

this.onMouseMove = function()
{
initialize(); // erase previous line and create a new one
_root.mid_mc._x = _root.mouse_mc._x + (_root.start_mc._x - _root.mouse_mc._x)
* 1.1;
_root.mid_mc._y = _root.mouse_mc._y -30;
mc.lineStyle(3, 0x002255, 100);
mc.moveTo(start_mc._x, start_mc._y);
mc.curveTo(mid_mc._x, mid_mc._y,_root.mouse_mc._x,_root.mouse_mc._y);
}

this.onMouseDown = function()
{
if(_root.mouse_mc.hitTest(_root._xmouse, _root._ymouse))
{
_root.mouse_mc.startDrag(false);
}
}

this.onMouseUp = function()
{
stopDrag();
}

Re: Line follow cursor jdh239
3/6/2006 4:04:23 AM
I really don't know actionscript that well, and I don't know if this would
help, but I would just create a box, make it a button, drag frame 1 to frame 4
inside the button, add actionscript that said:

on (rollOver){
gotoAndPlay("somewhere")
}
Re: Line follow cursor twistedpancreas
3/7/2006 10:49:12 PM
kind defeats the purpose of having the move mouse around code on it though
doesn't it?

basically i'd like the mouse to be able to be moved around freely, but when
released at a certain point on the screen it will then tell the timeline to
jump to a certain frame (ie a next screen)
Re: Line follow cursor NSurveyor
3/8/2006 11:11:44 PM
How about.. http://swf.befallin.com/experiments/mouse_sim/ ?

In the release code (onMouseUp), you can do your logical testing. If you
explain more on what you are checking for, we can help you better.
Re: Line follow cursor jdh239
3/12/2006 10:12:21 PM
Re: Line follow cursor twistedpancreas
3/14/2006 3:42:12 AM
that looks good NSurveyor i'll get back to you, and sorry i can't show the site
cause it's not available to the public yet, i might try a skeleton version of
it to show you what i want, but NSurveyor's file might be a go'er.
AddThis Social Bookmark Button