# Need help adapting/advancing my AS

**URL:** https://forum.kirupa.com/t/need-help-adapting-advancing-my-as/8440
**Category:** flash
**Created:** [November 21, 2002, 8:20am UTC](https://forum.kirupa.com/t/need-help-adapting-advancing-my-as/8440 "2002-11-21T08:20:24Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![yorkshirepuddin](https://avatars.discourse-cdn.com/v4/letter/y/aeb1de/32.png) [@yorkshirepuddin](https://forum.kirupa.com/u/yorkshirepuddin)
#### Post date: [November 21, 2002, 8:20am UTC](https://forum.kirupa.com/t/need-help-adapting-advancing-my-as/8440/1 "2002-11-21T08:20:24Z")

</div>

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](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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 21, 2002, 8:27am UTC](https://forum.kirupa.com/t/need-help-adapting-advancing-my-as/8440/2 "2002-11-21T08:27:17Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 21, 2002, 8:32am UTC](https://forum.kirupa.com/t/need-help-adapting-advancing-my-as/8440/3 "2002-11-21T08:32:41Z")

</div>

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).

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 21, 2002, 8:41am UTC](https://forum.kirupa.com/t/need-help-adapting-advancing-my-as/8440/4 "2002-11-21T08:41:50Z")

</div>

> \*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.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 21, 2002, 8:44am UTC](https://forum.kirupa.com/t/need-help-adapting-advancing-my-as/8440/5 "2002-11-21T08:44:22Z")

</div>

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)

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 21, 2002, 8:48am UTC](https://forum.kirupa.com/t/need-help-adapting-advancing-my-as/8440/6 "2002-11-21T08:48:16Z")

</div>

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

Thanks for your help.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 21, 2002, 8:51am UTC](https://forum.kirupa.com/t/need-help-adapting-advancing-my-as/8440/7 "2002-11-21T08:51:40Z")

</div>

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

Just remember these key things

if

\_y

\<

lowmax

\_y

=

lowmax

LOL, hope these key things help you 🙂

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 21, 2002, 8:54am UTC](https://forum.kirupa.com/t/need-help-adapting-advancing-my-as/8440/8 "2002-11-21T08:54:37Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 21, 2002, 6:25pm UTC](https://forum.kirupa.com/t/need-help-adapting-advancing-my-as/8440/9 "2002-11-21T18:25:45Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 21, 2002, 6:46pm UTC](https://forum.kirupa.com/t/need-help-adapting-advancing-my-as/8440/10 "2002-11-21T18:46:20Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 21, 2002, 6:52pm UTC](https://forum.kirupa.com/t/need-help-adapting-advancing-my-as/8440/11 "2002-11-21T18:52:43Z")

</div>

> \*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.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 21, 2002, 6:55pm UTC](https://forum.kirupa.com/t/need-help-adapting-advancing-my-as/8440/12 "2002-11-21T18:55:13Z")

</div>

Oh ok.

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 21, 2002, 7:05pm UTC](https://forum.kirupa.com/t/need-help-adapting-advancing-my-as/8440/13 "2002-11-21T19:05:52Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 21, 2002, 7:06pm UTC](https://forum.kirupa.com/t/need-help-adapting-advancing-my-as/8440/14 "2002-11-21T19:06:40Z")

</div>

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 …

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 21, 2002, 7:08pm UTC](https://forum.kirupa.com/t/need-help-adapting-advancing-my-as/8440/15 "2002-11-21T19:08:02Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 21, 2002, 7:13pm UTC](https://forum.kirupa.com/t/need-help-adapting-advancing-my-as/8440/16 "2002-11-21T19:13:52Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 21, 2002, 7:15pm UTC](https://forum.kirupa.com/t/need-help-adapting-advancing-my-as/8440/17 "2002-11-21T19:15:04Z")

</div>

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

```
_y += (endY-_y)/speed;

```

am i getting close?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 21, 2002, 7:52pm UTC](https://forum.kirupa.com/t/need-help-adapting-advancing-my-as/8440/18 "2002-11-21T19:52:31Z")

</div>

I think I’ve done it. 🙂 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?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 21, 2002, 8:07pm UTC](https://forum.kirupa.com/t/need-help-adapting-advancing-my-as/8440/19 "2002-11-21T20:07:04Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 21, 2002, 8:13pm UTC](https://forum.kirupa.com/t/need-help-adapting-advancing-my-as/8440/20 "2002-11-21T20:13:58Z")

</div>

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?

[Next page](https://forum.kirupa.com/t/need-help-adapting-advancing-my-as/8440.md?page=2)
