# Positioneing of mc

**URL:** https://forum.kirupa.com/t/positioneing-of-mc/16472
**Category:** Uncategorized
**Created:** [March 25, 2003, 3:28pm UTC](https://forum.kirupa.com/t/positioneing-of-mc/16472 "2003-03-25T15:28:20Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![mooler](https://avatars.discourse-cdn.com/v4/letter/m/b4bc9f/32.png) [@mooler](https://forum.kirupa.com/u/mooler)
#### Post date: [March 25, 2003, 3:28pm UTC](https://forum.kirupa.com/t/positioneing-of-mc/16472/1 "2003-03-25T15:28:20Z")

</div>

Howdy  
I found this in the kirupa tuts.

[AS]onClipEvent (load) {  
\_x = 0;  
\_y = 0;  
speed = 5;  
}  
onClipEvent (mouseDown) {  
endX = \_root.\_xmouse;  
endY = \_root.\_ymouse;  
}  
onClipEvent (enterFrame) {  
\_x += (endX-\_x)/speed;  
\_y += (endY-\_y)/speed;  
}  
[/AS]

It makes the mc move to the position where the mouse is clicked ( just to clerify that).

Now I´m trying to learn AS but need help on this to get started.

I want a MC to move to a preset position when a button is clicked.  
So for instance when I click a “news” button the mc slides horisontally to the news button and stops underneath it.

What should I use to do this.

Thx

---

<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: [March 25, 2003, 3:37pm UTC](https://forum.kirupa.com/t/positioneing-of-mc/16472/2 "2003-03-25T15:37:42Z")

</div>

instead of setting endX and endY to the mouse location, set them to your pre-defined location

---

<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: [March 25, 2003, 3:52pm UTC](https://forum.kirupa.com/t/positioneing-of-mc/16472/3 "2003-03-25T15:52:35Z")

</div>

Ok thx

But won´t that just move the mc to the same spot every time the mouse is down. I´d like to have it moving around to different positions when different buttons are clicked.

So this is what I´m thinking (emberassed)…

Do I put the x and y position for the mc in the button action ( and how do I manage that). Or do I use some kind of listner from the main timeline to check when a button is clicked and then tell to mc to move to a preset position based on wich button was clicked?

Am I complicating things?

---

<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: [March 25, 2003, 3:58pm UTC](https://forum.kirupa.com/t/positioneing-of-mc/16472/4 "2003-03-25T15:58:19Z")

</div>

Ok, buttons can have code in them too… this way each button can have it’s own behavior

if you want to make a button to change the position of the movie clip, this is the code you should put in your button. lets say your movie is called monkey, and you want the move clip to go to (30,30)

```auto

on(release){
_root.monkey.endX = 30
_root.monkey.endY = 30
}
[/AS] 

the onClip(enterFrame) on the movie you want to make should take care of the animation. That's always on.
```

---

<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: [March 25, 2003, 4:09pm UTC](https://forum.kirupa.com/t/positioneing-of-mc/16472/5 "2003-03-25T16:09:52Z")

</div>

Right on man!!!

That´s exactly the effect a was after, thanks a million.

Really appreciate it.

Phew!!! At last I can move on it´s a slow progress learning AS on your own (thank god for kirupa).

---

<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: [March 25, 2003, 4:52pm UTC](https://forum.kirupa.com/t/positioneing-of-mc/16472/6 "2003-03-25T16:52:20Z")

</div>

Ops spoke to soon.

It works fine with the exception that the MC moves up to teh lefthand corner in the beginning of the movie.

Tried this in the first frame of the main timeline but with no success  
[AS]  
on(enterFrame){  
\_root.monkey.endX = 100  
\_root.monkey.endY = 100  
}  
[/AS]

Hope you bear with me on this one.

---

<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: [March 25, 2003, 10:21pm UTC](https://forum.kirupa.com/t/positioneing-of-mc/16472/7 "2003-03-25T22:21:35Z")

</div>

Try this instead.[AS]\_root.monkey.onEnterFrame = function() {  
\_root.monkey.\_x = 100;  
\_root.monkey.\_y = 100;  
};[/AS]  
Replace your script with this one. 😛

---

<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: [March 25, 2003, 10:44pm UTC](https://forum.kirupa.com/t/positioneing-of-mc/16472/8 "2003-03-25T22:44:13Z")

</div>

> \*Originally posted by mooler \*  
> \*\*Ops spoke to soon.

It works fine with the exception that the MC moves up to teh lefthand corner in the beginning of the movie.

Tried this in the first frame of the main timeline but with no success  
[AS]  
on(enterFrame){  
\_root.monkey.endX = 100  
\_root.monkey.endY = 100  
}  
[/AS]

Hope you bear with me on this one. \*\*

ok… what are you talking about though? are you talking about what you’re doing with the button, or with the movie?

you can’t put an on Event handler in a frame, it needs to be in a button or a movie.

---

<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: [June 22, 2003, 1:48pm UTC](https://forum.kirupa.com/t/positioneing-of-mc/16472/9 "2003-06-22T13:48:16Z")

</div>

hey guys as you all are saying… Does the MC moves from point A to point B or it juz disappears from point A then appear in point B again like teleporting???

---

<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: [June 22, 2003, 2:26pm UTC](https://forum.kirupa.com/t/positioneing-of-mc/16472/10 "2003-06-22T14:26:02Z")

</div>

It moves like a motion tween.

---

<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: [June 22, 2003, 2:30pm UTC](https://forum.kirupa.com/t/positioneing-of-mc/16472/11 "2003-06-22T14:30:11Z")

</div>

Sorry p020385 I gave you the wrong thread url it´s this one  
[http://www.kirupaforum.com/forums/showthread.php?s=&threadid=18567](http://www.kirupaforum.com/forums/showthread.php?s=&threadid=18567)

This one is not the one I meant, sorry again ☹
