Positioneing of mc

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

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

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?

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)


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.

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

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.

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

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

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???

It moves like a motion tween.

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

This one is not the one I meant, sorry again :frowning: