-
mouse follower that allways returns to start?
I would like to make a mouse follower that only moves up and down and allways returns back to the same place every time the mouse moves off of the movie. I want to use it for a web page menu. I am a beginner so any help would be greately appreciated, Thanks!
-
Can't be that hard can it? Any idea's anyone?
-
I'm still trying, Didn't think this would stump everyone.
-
here's a file i made to get you started. there's one movieClip on the stage. it'll follow the mouse along the y axis as long as the mouse is within a defined area. I have the area in the sample defined as within the first 100 pixels along the y axis. So if the mouse is within 0 and 100 pixels then the mc will follow the mouse. If it moves out of this area then the mc returns to it's predefined position. Check it out, hope this is what your looking for or at least gets you on the right track.
Ohhhh jeez.......not again.
-
Cool , Thanks for the reply, but my version of Flash MX doesn't want to open your file? (Flash MX - unexpected file format) I was really looking forward to checking it out.
-
Could anyone with Flash 6 convert the attached file above (drag.fla) to open in Flash MX, Please!
-
Does anybody know were I can download a trial of Flash 6 ?
The More I Learn, The Less I Know!
-
You can do it all with script, avoiding file format problems. Make a movie clip, put an instance on the stage and name it rat. Then place the following code in frame 1 of your main timeline. (Alternatively, use your preferred method to make this the rat's onEnterFrame behavior.)
Code:
xhome = yhome = 40;
function follow() {
if(_xmouse > 0 && _xmouse < 200 && _ymouse > 0 && _ymouse < 200) {
this._x = _xmouse;
this._y = _ymouse;
} else {
this._x = .75 * this._x + .25 * xhome;
this._y = .75 * this._y + .25 * yhome;
}
}
rat.onEnterFrame = follow;
-
Thanks mkantor, but it didn't work for me?
The More I Learn, The Less I Know!
-
Yes mkantor, I got it working, not sure what I was doing wrong, but anyway I removed a line of code (this._x = _xmouse
to stop rat moving in the x axis as I only need movement up and down. Seems to be working o.k. what do you think?
anyway thanks heaps, I'll go play!
The More I Learn, The Less I Know!
-
here's an Mx version of the file I made. sorry I forget that MX 04 still isn't used that much. it's basically the same as mkantors script but a little less code because everything is in one onClipEvent. have fun.
Ohhhh jeez.......not again.
-
well $h1T, I tried opening my attachment on a PC and it still wasn't working for some reason....maybe cause it's made on a Mac. Oh well. Make a movie clip and attach this code to it. this was way more trouble then it was worth, lol. hope it helps you, have fun.
code: onClipEvent(enterFrame){
/*in the if statement the numbers 100 and 0 are the "bounds".
so if the mouse cursor is within 0 and 100 pixels it will
follow the mouse. once it leaves this range, say the
mouse is on the 101 pixel then drag_mc will return to
whichever number you fill in in the "else if(this._y > 0)"
hope this helps*/
if (_root._ymouse < 100 && _root._ymouse > 0){
var dist = _root._ymouse - this._y;
if(this._y != _root._ymouse){
this._y += .15 * dist;
}
} else if( this._y > 0 ) {
this._y *= .9;
}
}
Ohhhh jeez.......not again.
-
Thanks quovadimus02, works fine, but is there a way to limit the distance it moves down? say I have a movie 600 pixels high and I only want an mc to follow the curser down to 400 pixels?
Thanks again to everyone!
The More I Learn, The Less I Know!
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
|