Need help adapting/advancing my AS

After solving my previous problem, I had to go and make it a little harder on myself :crazy:, but I guess you learn through experimentation right?

Anyway, it’s a little beyond my knowledge of AS and would appreciate some help.

Okay, here’s my situtation.

I have 3 MC’s that are functioning as buttons. All 3 MC’s have the following AS attached to them:

[SIZE=1]onClipEvent (enterFrame) {
mousey = _root._Ymouse;
if (mousey<_y) {
followmouse = _y-mousey;
} else {
followmouse = mousey-_y;
}
moveSpeedy = followmouse/10;
if (mousey<_y) {
_y = _y-movespeedy;
} else {
_y = _y+movespeedy;
}
}
onClipEvent (enterFrame) {
if (this._y<8) {
this._y = 8;
}
if (this._y>232) {
this._y = 232;
}
}
{[/SIZE]

Ignore the settings for the min and max Y postion, I need to refigure those out.

Anyway, each clip is positioned appoximately 20 pixels apart on the Y.

So, when they follow the mouse, I would like the separation to remain - meaning the never sit at the same x position. Also, if you go to this URL to see it - http://members.rogers.com/limee/test/navigation.html - you’ll note that its pretty difficult to perform the rollover function (it works fine without the mouse follow).

I think that’s it. I half asleep so I may have more in the morgan.

Hope someone can help.

YP

HOLD THAT THOUGHT! I think I may almost have it and I’d like the challenge instead of bumming knowledge off everyone.

I’ll be back (but hopefully not).

YP

Well here are some tips on your journey…

The buttons are offset from your mouse, this means that as the mouse approaches them, there is no way it can catch up, because they move away from the mouse.

YOu could prevent this by A)Making them stop moving at a certain point or B)Not have them move away from the mouse (lol).

*Originally posted by lostinbeta *
**
YOu could prevent this by A)Making them stop moving at a certain point or B)Not have them move away from the mouse (lol). **

Thanks for the tips. I need 'um. Not going as well as I thought, but lack of sleep may be the culprit.

you can define a maxhigh y position and a maxlow y position and use if statements to stop them at each of the points so they don’t go any further from the mouse (or just a maxlow position really)

That sounds great, shame I don’t know how to do it. Got myself a challenge for the morning now.

Thanks for your help.

no problem… that last hint was a big one… I hope you can work with that tomorrow :slight_smile:

Just remember these key things

if

_y

<

lowmax

_y

=

lowmax

LOL, hope these key things help you :slight_smile:

It all sounds great what you’re saying. Let’s see what tomorrow brings. You set me a challenge now, I shall deliver.:stuck_out_tongue:

lost … you there? i need some clues … but not direct solutions … i want to figure this out on my own as much as possible …

btw … i found another script and used that … now of each MC I have the following:

[SIZE=1]// Detect Y coordinate of mouse and follow
onClipEvent (load) {
speed = 5;
}
onClipEvent (enterFrame) {
endY = _root._ymouse;
_y += (endY-_y)/speed;
if (this._y<-80) {
this._y = -80;
}
if (this._y>143) {
this._y = 143;
}
}
[/SIZE]

The only this that changes is the speed … I have it set to 5, 10, and 15 so each MC comes down/up at a different offset …

Hope you’re around.
YP

Why do you have a negative value for the max low?

*Originally posted by lostinbeta *
**Why do you have a negative value for the max low? **

sorry, you lost me … where do i have that?

oh you mean the - 80? well, when i play this thing over, with - 80 it stops at the right point.

Oh ok.

Well if it stops at the right point… then what is the situation? What isn’t working?

Okay, let’s go from the top.

I’ve just reformatted the AS to make more sense and combined on ClipEvents … here’s the code now.

// Detect Y coordinate of mouse and follow
onClipEvent (enterFrame) {
speed = 5;
endY = _root._ymouse;
_y += (endY-_y)/speed;
if (this._y<- 80) {
this._y = - 80;
}
if (this._y>143) {
this._y = 143;
}
}

Okay, so here’s what I need to figure out. I still have the same problems as last night, i.e. the boxes never reach the mouse pointer so the user won’t be able to activate the button.

Let’s sort that first.

Now, you mentioned something about Maxhigh and Max low … is this what I need to implement next to make the buttons able to reach the pointer.

Btw, truely, thanks for the help here, i’m sure you got better things to do, so I really appreciate it. It helps having someone actually guide you through as opposed to doing a tut.

Plus, I prefer to work it out myself so that I understand it better.
YP

Just to add, the only time the user is able to activate the MC buttons is when they are at the max and min on the Y …

Ok, because your situation is that your boxes move away from your mouse, by defining contraints to how far the boxes can go will allow you to catch up to them because they will stop at a certain point.

Where have I don’t that - told them to move away?

So, I guess what you’re saying is, although they are to follow the mouse when it moves, there final destination will be at the same y of the mouse?

I’m guessing I need to change or add to this part:

_y += (endY-_y)/speed;

am i getting close?

I think I’ve done it. :slight_smile: I didn’t actually have to change any of the AS, I just had to take all the MC’s out of an MC and drop them individually on the timeline.

Why would that be though?

Sorry I didn’t notice your second script was different from your first. Your first script had the buttons offset from the mouse so you could never touch them (as in the example link you showed).

Not sure what you mean about taking an mc out of an mc and placing it on the maintimeline and it worked.

If it was what I am thinking of, that really makes no sense.

I’m not suprised that I’m confusing you. It’s hard to explain stuff when you barely understand it yourself.

I’ll try and explain the structure I had and now have.

HAD

Originally, I had my main MC which was called Navigation. Within that MC, I had my three MC’s that act as the navigation for the site (i.e. section 1, 2 and 3). On each of those MC’s (the 3), I was assigning the AS we’ve been going over.

NOW HAVE

I have completely omitted the main MC and just dropped the 3 MCs on the main stage timeline and again applied the AS to them.

Understand now?