|
-
MC follows the cursor with bounce?
I know how to make a movieclip follow the mouse cursor around a movie, but what I need to do is more similar to the www.sobebev.com navigation bar. That is, the item following the cursor should be limited to one axis, have a bit of bounce or sassyness to it, and disappear once the cursor leaves.
Any ideas on what the actionscript/math for this would look like?
-
Senior Member
I would suggest looking up various recent threads containing the word "spring" or "springy" - this subject comes up a lot here.
-
hi,
this is standard springy script. put it in the frame of the clip you want to have the effect. speed controls the speed of tracking the mouse; damp controls springiness. in the example, i am attaching a movie with symbol "mySymbolID" in the libe. replace mySymbolID with the clip you want to follow the mouse. if the clip is already on the stage, give it an instance name (i used "ball") and omit the attachMovie line of code.
code:
function FollowMouse() {
this.speed==undefined ? this.speed=.8 : null;
this.damp==undefined ? this.damp=.4 : null;
}
FollowMouse.prototype=new MovieClip();
FollowMouse.prototype.followYMouse = function() {
var bY = 0;
this.onEnterFrame = function() {
bY += (_root._ymouse-this._y)*this.speed;
bY *= this.damp;
this._y += bY;
};
};
Object.registerClass("mySymbolID",FollowMouse);
var ball = this.attachMovie("mySymbolID", "ball", 0);
ball.speed=.8;
ball.damp=.4;
ball.followYMouse();
good luck and take care
brint
-
Originally posted by brintcorb
if the clip is already on the stage, give it an instance name (i used "ball") and omit the attachMovie line of code.
Ok, maybe I haven't had enough coffee yet, but while your script as written works perfectly, I'd rather control an item already on the stage. However when I remove the "attachmovie" line, the script no longer works. What bone-headed thing am I forgetting?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|