# Xy positioning of movieclip-button

**URL:** https://forum.kirupa.com/t/xy-positioning-of-movieclip-button/183188
**Category:** Uncategorized
**Created:** [March 24, 2006, 2:28pm UTC](https://forum.kirupa.com/t/xy-positioning-of-movieclip-button/183188 "2006-03-24T14:28:56Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![kos010](https://avatars.discourse-cdn.com/v4/letter/k/77aa72/32.png) [@kos010](https://forum.kirupa.com/u/kos010)
#### Post date: [March 24, 2006, 2:28pm UTC](https://forum.kirupa.com/t/xy-positioning-of-movieclip-button/183188/1 "2006-03-24T14:28:56Z")

</div>

hey guys & girls,  
I’ve gotta questions. I want to realize a button that is inside a movieclip, which traces the mousetrail. When the user clicks on the button, the movieclip goes to a certain location where it stays…  
my as knowledge is poor, and I just can’t get out how these guys do it: [http://www.wireframe.co.za/w1r3d.html](http://www.wireframe.co.za/w1r3d.html)

thanks for the hints you can give me !

chris

---

<div class="post-metadata">

### Author: ![pensamente](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/pensamente/32/1208_2.png) [@pensamente](https://forum.kirupa.com/u/pensamente)
#### Post date: [March 24, 2006, 3:25pm UTC](https://forum.kirupa.com/t/xy-positioning-of-movieclip-button/183188/2 "2006-03-24T15:25:50Z")

</div>

[AS]stop();  
speed = 50;  
onEnterFrame = function () {  
endX = \_root.\_xmouse;  
endY = \_root.\_ymouse;  
yourMC.\_x += (endX-yourMC.\_x)/speed;  
yourMC.\_y += (endY-yourMC.\_y)/speed;  
};  
[/AS]

try this for the mouse trail

---

<div class="post-metadata">

### Author: ![pensamente](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/pensamente/32/1208_2.png) [@pensamente](https://forum.kirupa.com/u/pensamente)
#### Post date: [March 24, 2006, 3:32pm UTC](https://forum.kirupa.com/t/xy-positioning-of-movieclip-button/183188/3 "2006-03-24T15:32:21Z")

</div>

[AS]  
stop();  
import mx.transitions.Tween;  
import mx.transitions.easing.\*;  
//  
speed = 50;  
onEnterFrame = function () {  
endX = \_root.\_xmouse;  
endY = \_root.\_ymouse;  
yourMC.\_x += (endX-yourMC.\_x)/speed;  
yourMC.\_y += (endY-yourMC.\_y)/speed;  
};  
//  
yourMC.onRelease = function() {  
var tweenx:Tween = new Tween(yourMC, “\_x”, Strong.easeInOut, yourMC.\_x, 100, 2, true);  
var tweeny:Tween = new Tween(yourMC, “\_y”, Strong.easeInOut, yourMC.\_y, 100, 2, true);  
delete \_root.onEnterFrame;  
};  
[/AS]

that will do if you apply it on \_root with a mc with instance name yourMC  
hope that helps…

am

---

<div class="post-metadata">

### Author: ![kos010](https://avatars.discourse-cdn.com/v4/letter/k/77aa72/32.png) [@kos010](https://forum.kirupa.com/u/kos010)
#### Post date: [March 27, 2006, 8:58am UTC](https://forum.kirupa.com/t/xy-positioning-of-movieclip-button/183188/4 "2006-03-27T08:58:00Z")

</div>

> [@pensamente](#):
>
> ```
> ActionScript Code:
> [FONT=Courier New][LEFT][COLOR=#0000FF]stop[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
> 
> ```
> 
> [COLOR=#0000FF]import[/COLOR] mx.[COLOR=#000080]transitions[/COLOR].[COLOR=#000080]Tween[/COLOR];  
> [COLOR=#0000FF]import[/COLOR] mx.[COLOR=#000080]transitions[/COLOR].[COLOR=#000080]easing[/COLOR]._;  
> [COLOR=#808080]_//_[/COLOR]  
> speed = [COLOR=#000080]50[/COLOR];  
> [COLOR=#0000FF]onEnterFrame[/COLOR] = [COLOR=#000000] **function** [/COLOR] COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
> endX = [COLOR=#0000FF]\_root[/COLOR].[COLOR=#0000FF]\_xmouse[/COLOR];  
> endY = [COLOR=#0000FF]\_root[/COLOR].[COLOR=#0000FF]\_ymouse[/COLOR];  
> yourMC.[COLOR=#0000FF]\_x[/COLOR] += COLOR=#000000[/COLOR]/speed;  
> yourMC.[COLOR=#0000FF]\_y[/COLOR] += COLOR=#000000[/COLOR]/speed;  
> [COLOR=#000000]}[/COLOR];  
> [COLOR=#808080]_//\*[/COLOR]  
> yourMC.[COLOR=#0000FF]onRelease[/COLOR] = [COLOR=#000000] **function** [/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
> &nbsp;&nbsp;&nbsp;&nbsp;var tweenx:Tween = [COLOR=#000000] **new** [/COLOR] Tween[COLOR=#000000]([/COLOR]yourMC, [COLOR=#FF0000]“\_x”[/COLOR], Strong.[COLOR=#000080]easeInOut[/COLOR], yourMC.[COLOR=#0000FF]\_x[/COLOR], [COLOR=#000080]100[/COLOR], [COLOR=#000080]2[/COLOR], [COLOR=#000000] **true** [/COLOR][COLOR=#000000])[/COLOR];  
> &nbsp;&nbsp;&nbsp;&nbsp;var tweeny:Tween = [COLOR=#000000] **new** [/COLOR] Tween[COLOR=#000000]([/COLOR]yourMC, [COLOR=#FF0000]“\_y”[/COLOR], Strong.[COLOR=#000080]easeInOut[/COLOR], yourMC.[COLOR=#0000FF]\_y[/COLOR], [COLOR=#000080]100[/COLOR], [COLOR=#000080]2[/COLOR], [COLOR=#000000] **true** [/COLOR][COLOR=#000000])[/COLOR];  
> &nbsp;&nbsp;&nbsp;&nbsp;delete [COLOR=#0000FF]\_root[/COLOR].[COLOR=#0000FF]onEnterFrame[/COLOR];  
> [COLOR=#000000]}[/COLOR];  
> [/LEFT]  
> [/FONT]
> 
> that will do if you apply it on \_root with a mc with instance name yourMC  
> hope that helps…
> 
> am

Hi Pensamente,

thanks for the reply and tips. I got the movieclip with the mousetrailer effect, so that is one part. However, when I import the transition.tween and easing class, I get a syntax error in my code. Leaving them out of the AS doesnt help (duh=]) but the logo freezes when it is clicked.

My question… How do I properly intergrate that transition/tweening/easing class in the script? do I have to code something extra (location of x & Y after the release?)

I have in the first layer the as you gave me. in the second layer I’ve got a movieclip with the name yourMC. Where did i go wrong?

---

<div class="post-metadata">

### Author: ![kos010](https://avatars.discourse-cdn.com/v4/letter/k/77aa72/32.png) [@kos010](https://forum.kirupa.com/u/kos010)
#### Post date: [March 27, 2006, 9:22am UTC](https://forum.kirupa.com/t/xy-positioning-of-movieclip-button/183188/5 "2006-03-27T09:22:21Z")

</div>

ok, this is really strange… I made a new document and it seems the work! now I’ve got a new question… how can I tell the movieclip that it should go to the middle of the movie when it’s been clicked?

Edit: got that also now… thanks again !

---

<div class="post-metadata">

### Author: ![pensamente](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/pensamente/32/1208_2.png) [@pensamente](https://forum.kirupa.com/u/pensamente)
#### Post date: [March 27, 2006, 9:35am UTC](https://forum.kirupa.com/t/xy-positioning-of-movieclip-button/183188/6 "2006-03-27T09:35:26Z")

</div>

sorry the no reply, but i was out this weekend  
nice to know u got your questions solved 😉

.am

---

<div class="post-metadata">

### Author: ![kos010](https://avatars.discourse-cdn.com/v4/letter/k/77aa72/32.png) [@kos010](https://forum.kirupa.com/u/kos010)
#### Post date: [March 27, 2006, 10:06am UTC](https://forum.kirupa.com/t/xy-positioning-of-movieclip-button/183188/7 "2006-03-27T10:06:17Z")

</div>

> [@pensamente](#):
>
> sorry the no reply, but i was out this weekend  
> nice to know u got your questions solved 😉
> 
> .am

hehe I was out to, tried to understand the script this morning after a quick review last friday…  
Now I’m trying to have a transition between the logo and the actual content. Let’s have a livedocs moment =]
