Forum Topic: AS: Elastic mouse follower

(5,311 views • 32 replies)

This topic is 2 pages long. [ 1 | 2 ]

<< < > >>
Thinking

lan00

Reply To Post Reply & Quote

Posted at: 9/6/05 05:48 AM

lan00 EVIL LEVEL 07

Sign-Up: 05/20/05

Posts: 217

=======
INTRO
=======

ok in this tutorial you will learn how to make a object follow the mouse BUT when it gets to the mouse it is elastic
(kid of like this TUT but follows the mouse)

ok heres what to do.
=====
Let's Make This Thing
=====

1.Create a circle and convert it to a MC (F8)

2. in that MC on frame 1 put these actions in it

physics0 = .50;
//speed at which the ball move towards the cursor
physics1 = .50;
//the stop at the cursor rate

xspeed = ((_root._xmouse-_x)*physics0)+(xspeed*phys
ics1);
yspeed = ((_root._ymouse-_y)*physics0)+(yspeed*phys
ics1);

// add the speed to the current position of the ball
_x += xspeed;
_y += yspeed;

3. add a Keyframe onto frame 2 (F6)

4.Push CTRL and ENTER together and CONGRATULATIONS it is finished

Hope this Tutorial has helped you
Please reply any questions
Thanks


None

JackSmack

Reply To Post Reply & Quote

Posted at: 9/6/05 05:52 AM

JackSmack DARK LEVEL 14

Sign-Up: 11/11/04

Posts: 1,122

That is already covered I think...

http://www.newground../topic.php?id=299438

it's easy to change the code in the other post.. just change the target to _xmouse and _ymouse and drop the modes.

Visit JackSmack.com and submit your Flash Movies and Games!

BBS Signature

None

lan00

Reply To Post Reply & Quote

Posted at: 9/6/05 05:54 AM

lan00 EVIL LEVEL 07

Sign-Up: 05/20/05

Posts: 217

yeah

i saw the elastic ball in the bbs and i made a whole new one but it follows the mouse

oh well it is a new AS tutorial


None

brotherkipling

Reply To Post Reply & Quote

Posted at: 10/1/05 09:11 AM

brotherkipling EVIL LEVEL 02

Sign-Up: 01/21/05

Posts: 23

Your tutorials fail.


None

Toast

Reply To Post Reply & Quote

Posted at: 10/1/05 09:13 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,414

Your tutorials aren't:

- Long enough.

- Descriptive enough.

- Don't contain comments.

- Do not actually teach a lot.

- Are copy & paste tutorials.

I put on my robe and wizard hat

Why don't you check out my check out my userpage?

BBS Signature

None

Rustygames

Reply To Post Reply & Quote

Posted at: 10/1/05 09:17 AM

Rustygames LIGHT LEVEL 18

Sign-Up: 05/07/05

Posts: 6,429

lan00 YOU ARE A FUCKING N00B and you know NOTHING about AS so stop making shag tutorials dick lover

Now I got that off my chest who wants to make love?

- Matt, Rustyarcade.com


None

Rantzien

Reply To Post Reply & Quote

Posted at: 10/1/05 09:18 AM

Rantzien FAB LEVEL 15

Sign-Up: 01/27/05

Posts: 3,422

At 10/1/05 09:17 AM, Ninja-Chicken wrote:
Now I got that off my chest who wants to make love?

Me want a secks please.

BBS Signature

None

Rustygames

Reply To Post Reply & Quote

Posted at: 10/1/05 09:21 AM

Rustygames LIGHT LEVEL 18

Sign-Up: 05/07/05

Posts: 6,429

At 10/1/05 09:18 AM, Rantzien wrote:
At 10/1/05 09:17 AM, Ninja-Chicken wrote:
Now I got that off my chest who wants to make love?
Me want a secks please.

lets do it suger

Actualy do I have you on msn? I think you should add me so I can put you in my AS section (only inglor and delta were good enough to go in there so consider yourself pro)

- Matt, Rustyarcade.com


None

Rantzien

Reply To Post Reply & Quote

Posted at: 10/1/05 09:26 AM

Rantzien FAB LEVEL 15

Sign-Up: 01/27/05

Posts: 3,422

At 10/1/05 09:21 AM, Ninja-Chicken wrote: lets do it suger

Actualy do I have you on msn? I think you should add me so I can put you in my AS section (only inglor and delta were good enough to go in there so consider yourself pro)

Oh em gee =)
Sure, I'll add you

BBS Signature

None

Starogre

Reply To Post Reply & Quote

Posted at: 10/1/05 09:57 AM

Starogre NEUTRAL LEVEL 18

Sign-Up: 05/08/04

Posts: 1,501

xspeed = ((_root._xmouse-_x)*physics0)+(xspeed*phys
ics1);
yspeed = ((_root._ymouse-_y)*physics0)+(yspeed*phys
ics1);

Explain what that does, please.

BBS Signature

None

Vortex

Reply To Post Reply & Quote

Posted at: 10/11/05 04:39 PM

Vortex LIGHT LEVEL 09

Sign-Up: 08/27/05

Posts: 672

would be better if it actually worked


None

SEXY-FETUS

Reply To Post Reply & Quote

Posted at: 10/11/05 04:45 PM

SEXY-FETUS NEUTRAL LEVEL 05

Sign-Up: 05/02/05

Posts: 1,343

make it easier on yourself
onClipEvent(load){
physics0 = .50;
physics1 = .50;
}
onClipEvent(enterFrame){
xspeed = ((_root._xmouse-_x)*physics0)+(xspeed*phys
ics1);
yspeed = ((_root._ymouse-_y)*physics0)+(yspeed*phys
ics1);
_x += xspeed;
_y += yspeed;
}
Alot cleaner and doesn't give you that bumpy effect


None

Vortex

Reply To Post Reply & Quote

Posted at: 10/11/05 04:47 PM

Vortex LIGHT LEVEL 09

Sign-Up: 08/27/05

Posts: 672

At 10/11/05 04:45 PM, SEXY_FETUS wrote: make it easier on yourself
onClipEvent(load){
physics0 = .50;
physics1 = .50;
}
onClipEvent(enterFrame){
xspeed = ((_root._xmouse-_x)*physics0)+(xspeed*phys
ics1);
yspeed = ((_root._ymouse-_y)*physics0)+(yspeed*phys
ics1);
_x += xspeed;
_y += yspeed;
}
Alot cleaner and doesn't give you that bumpy effect

..doesent work either...


None

SEXY-FETUS

Reply To Post Reply & Quote

Posted at: 10/11/05 04:47 PM

SEXY-FETUS NEUTRAL LEVEL 05

Sign-Up: 05/02/05

Posts: 1,343

At 10/1/05 09:57 AM, Starogre wrote: xspeed = ((_root._xmouse-_x)*physics0)+(xspeed*phys
ics1);
yspeed = ((_root._ymouse-_y)*physics0)+(yspeed*phys
ics1);

Explain what that does, please.

that's just the bbs cutting stuff short it should be
(yspeed*physics1); so adjust that in your code

oh and sorry for the double post.


None

Vortex

Reply To Post Reply & Quote

Posted at: 10/11/05 04:57 PM

Vortex LIGHT LEVEL 09

Sign-Up: 08/27/05

Posts: 672

whatever its not working for me.


None

JeremysFilms

Reply To Post Reply & Quote

Posted at: 10/11/05 06:15 PM

JeremysFilms NEUTRAL LEVEL 17

Sign-Up: 02/18/05

Posts: 1,511

You didn't explain eahc part of the script or anything. This is not a tutorial, this is a copy/paste thread!


None

SEXY-FETUS

Reply To Post Reply & Quote

Posted at: 10/11/05 11:02 PM

SEXY-FETUS NEUTRAL LEVEL 05

Sign-Up: 05/02/05

Posts: 1,343

I think this is kinda a nice one to teach simple math functions and how they can be used. So what the hell I'll break it apart and it might help someone.
onClipEvent(load){//proprties in this tag are loaded once
physics0 = .5;//simple name with value in this case ".5" could be anything
physics1 = .5;//ditto
}//closes the "onclipevent" handler
onClipEvent(enterFrame){//properties in this will be updated every frame
//even if every timeline is stopped frames are updated at the ratio you set
xspeed = ((_root._xmouse-_x)*physics0)+(xspeed*phys
ics1);
//the x position of the mouse subtracted by the x position of the MC this code is place on
//multiplied by the first value set on the load plus itself multiplied by the second value
//breaks apart exactly the same as high school algebra
yspeed = ((_root._ymouse-_y)*physics0)+(yspeed*phys
ics1);
//same as above with y position instead of x
_x += xspeed;
//adds the sum of the xspeed equasion(speeling) to the mc's x position
//if that's confusing look for a tutorial on simple character movement
_y += yspeed;
//same as above except with y position
}//closes onclipevent again

Play with this a bit change values see what happens when you take away the y position handling and the x position handling


None

Thomas

Reply To Post Reply & Quote

Posted at: 10/12/05 01:29 AM

Thomas LIGHT LEVEL 13

Sign-Up: 02/14/05

Posts: 2,429

At 10/11/05 04:57 PM, Vortex wrote: whatever its not working for me.

Stop posting that.

Anyways,your code isn't achieving Syntax.It's error-ful.

Ixfay ouryay odecay.
Now shutup and learn pig latin.

Happy

Depredation

Reply To Post Reply & Quote

Posted at: 4/11/06 05:28 AM

Depredation LIGHT LEVEL 17

Sign-Up: 09/05/05

Posts: 4,498

This is more of a FOSS than a AS. Btw, tom you need to change your name. Retarded animal Babies 15 is out now, lol.

BBS Signature

None

RyanPridgeon

Reply To Post Reply & Quote

Posted at: 4/11/06 07:18 AM

RyanPridgeon LIGHT LEVEL 11

Sign-Up: 12/07/05

Posts: 1,947

hold up guys, i know why it doesnt work.

onClipEvent(load){
physics0 = 0.50;
physics1 = 0.50;
xspeed=0;
yspeed=0;
}
onClipEvent(enterFrame){
xspeed = ((_root._xmouse-_x)*physics0)+(xspeed*phys
ics1);
yspeed = ((_root._ymouse-_y)*physics0)+(yspeed*phys
ics1);
_x += xspeed;
_y += yspeed;
}

notice you have to give all variables SOMETHING to start out with. at the start it cant do xspeed*physics1 if xspeed is "undefined".

:D

I make flashes because I can.
PM me for anything flash or web related or visit my blog here on NG!
Also, here's my DICK

BBS Signature

None

Paradox

Reply To Post Reply & Quote

Posted at: 4/11/06 08:54 AM

Paradox LIGHT LEVEL 26

Sign-Up: 01/28/06

Posts: 9,726

At 4/11/06 07:18 AM, ryanpridgeon wrote: notice you have to give all variables SOMETHING to start out with. at the start it cant do xspeed*physics1 if xspeed is "undefined".

D

Originally there was only one error, now there is four.


Questioning

Link126

Reply To Post Reply & Quote

Posted at: 4/23/06 08:18 PM

Link126 LIGHT LEVEL 06

Sign-Up: 03/23/06

Posts: 158

I can't get anything to work. T_T Somebody help me. I'm a baffled noob


None

Khao

Reply To Post Reply & Quote

Posted at: 4/23/06 10:08 PM

Khao EVIL LEVEL 19

Sign-Up: 09/20/03

Posts: 2,767

At 10/1/05 09:21 AM, Ninja-chicken wrote:
lets do it suger

Actualy do I have you on msn? I think you should add me so I can put you in my AS section (only inglor and delta were good enough to go in there so consider yourself pro)

fuck you?


None

ImpotentBoy2

Reply To Post Reply & Quote

Posted at: 4/23/06 10:17 PM

ImpotentBoy2 LIGHT LEVEL 18

Sign-Up: 04/01/03

Posts: 5,039

at first i was gonna say that every eeryone should calm down.but when i looked at the code - in fact not even the code, the first instruction- i barfed. you do not even understand clip events. i understoon clip events literally the first day i tried flash. i looked at a sample, tried it out, understood it. you are so horrible its not even funny. then i looked at your code, half of it it not needed, why have 2 variables with the same value? why even have 2 varibles with something this simple?! because of that im sure you copy and pasted. although i dont know where you would find such a crappy tutorial.


None

ImpotentBoy2

Reply To Post Reply & Quote

Posted at: 4/23/06 10:19 PM

ImpotentBoy2 LIGHT LEVEL 18

Sign-Up: 04/01/03

Posts: 5,039

At 4/11/06 07:18 AM, ryanpridgeon wrote: hold up guys, i know why it doesnt work.

onClipEvent(load){
physics0 = 0.50;
physics1 = 0.50;
xspeed=0;
yspeed=0;
}
onClipEvent(enterFrame){
xspeed = ((_root._xmouse-_x)*physics0)+(xspeed*phys
ics1);
yspeed = ((_root._ymouse-_y)*physics0)+(yspeed*phys
ics1);
_x += xspeed;
_y += yspeed;
}

notice you have to give all variables SOMETHING to start out with. at the start it cant do xspeed*physics1 if xspeed is "undefined".

D

thats only if your using += or -=. you dont need to predefine things when your just using =, buts its a good idea. the problem is its just a horrible code.


None

RyanPridgeon

Reply To Post Reply & Quote

Posted at: 5/1/06 03:48 PM

RyanPridgeon LIGHT LEVEL 11

Sign-Up: 12/07/05

Posts: 1,947

problem is its just a horrible code

Amen.

I make flashes because I can.
PM me for anything flash or web related or visit my blog here on NG!
Also, here's my DICK

BBS Signature

None

joshy24

Reply To Post Reply & Quote

Posted at: 5/6/06 07:57 PM

joshy24 LIGHT LEVEL 06

Sign-Up: 11/28/04

Posts: 708

ok, guys, after months, i figured it out. And i feel like an idiot.

well it was a long time

after you copy and paste it, you need to fix the
phy
sics
or something like that. The point is, is that part of the code is entered
so the code would be
onClipEvent(load){
physics0 = 0.50;
physics1 = 0.50;
xspeed=0;
yspeed=0;
}
onClipEvent(enterFrame){
xspeed = ((_root._xmouse-_x)*physics0)+(xspeed*phys
ics1);
yspeed = ((_root._ymouse-_y)*physics0)+(yspeed*phys
ics1);
_x += xspeed;
_y += yspeed;
}

ok now check the xspeed*physics and the yspeed*physics, see?

Steam: imuffin101

BBS Signature

None

Hoeloe

Reply To Post Reply & Quote

Posted at: 5/7/06 07:22 AM

Hoeloe LIGHT LEVEL 22

Sign-Up: 04/29/04

Posts: 3,976

BTW, sexy_fetus, it's spelt feotus

I never claim to know everything, people just assume I do anyway.
------------------------------
THE LAST WIZARD AND THE DOOMSDAY RINGS NOW IN PRODUCTION!

BBS Signature

None

Scrub

Reply To Post Reply & Quote

Posted at: 5/25/06 08:33 PM

Scrub LIGHT LEVEL 09

Sign-Up: 05/19/05

Posts: 150

Ok guys I'm not lying to you when I say I have tinkered with this for hours and can't get it to work. I'm no asking to copy/paste but will someone give me somewhere to START?!


None

menzoic

Reply To Post Reply & Quote

Posted at: 12/10/06 07:16 PM

menzoic NEUTRAL LEVEL 02

Sign-Up: 10/23/06

Posts: 29

I don't know if anyone reads this tut anymore but the code is messed up, this is how it should look:
//put this on the movieclip and not inside it
onClipEvent(load){
physics0 = .50;
physics1 = .50;
}
onClipEvent(enterFrame){
xspeed = ((_root._xmouse - this._x)*physics0);
yspeed = ((_root._ymouse - this._y)*physics0);
xspeed += (xspeed*physics1);
yspeed += (yspeed*physics1);
this._x += xspeed;
this._y += yspeed;
trace(yspeed);
trace(xspeed);
}

The original with comments explaining the errors:

onClipEvent(enterFrame){
physics0 = .50;
//speed at which the ball move towards the cursor
physics1 = .50;
//the stop at the cursor rate

//----------------You can't assign a variable with a variable that is undefined------------
//xpeed is given the value of ((_root._xmouse-this._x)*physics0)+(XSPEED*ph ysics1);
//the capitalized XSPEED is undeined so xspeed gets nothing.
//The same goes for yspeed

xspeed = ((_root._xmouse-this._x)*physics0)+(xspeed*ph ysics1);
yspeed = ((_root._ymouse-this._y)*physics0)+(yspeed*ph ysics1);

// add the speed to the current position of the ball
this._x += xspeed;
this._y += yspeed;
}


All times are Eastern Standard Time (GMT -5) | Current Time: 11:14 AM

<< Back

This topic is 2 pages long. [ 1 | 2 ]

<< < > >>
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!