# \[FMX\] AS movement

**URL:** <https://forum.kirupa.com/t/fmx-as-movement/44824>\
**Category:** flash\
**Created:** [March 8, 2004, 7:42am UTC](https://forum.kirupa.com/t/fmx-as-movement/44824 "2004-03-08T07:42:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dboers](https://avatars.discourse-cdn.com/v4/letter/d/bbe5ce/32.png) [@dboers](https://forum.kirupa.com/u/dboers)\
**Post date:** [March 8, 2004, 7:42am UTC](https://forum.kirupa.com/t/fmx-as-movement/44824/1 "2004-03-08T07:42:45Z")

</div>

Hi,

I have added the following AS code to a movieclip called mc\_square:

[AS]onClipEvent (load) {  
speed = 3;  
yPos = 50;  
}  
onClipEvent (enterFrame) {  
endPos = yPos - \_y;  
\_y += endPos/speed;  
}[/AS]

I like to accomplish that, when rolling over mc-square, it’s \_y position becomes 150.

Right now I have an extra button on the stage with de following actionscript code:

[AS]on (RollOver) {  
mc\_square.yPos=150;  
}[/AS]

This is working. When rolling over the clip mc\_square is indeed moving to \_y position 150.  
As said instaed of working with a sepparate button I would like to attach the code to the movieclip mc\_square. I tried the following AS code but nothing happened:

[AS]mc\_square.onLoad= function(){  
speed = 3;  
yPos = 50;  
}  
mc\_square.onEnterFrame=function(){  
yEnd = yPos - \_y;  
\_y += yEnd/speed;  
}  
mc\_square.onRollOver=function(){  
this.yPos= 150;  
}[/AS]

Where am I going wrong :h:
