# Button triggered object movement

**URL:** <https://forum.kirupa.com/t/button-triggered-object-movement/11283>\
**Category:** Uncategorized\
**Created:** [January 14, 2003, 11:30pm UTC](https://forum.kirupa.com/t/button-triggered-object-movement/11283 "2003-01-14T23:30:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![shuga](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@shuga](https://forum.kirupa.com/u/shuga)\
**Post date:** [January 14, 2003, 11:30pm UTC](https://forum.kirupa.com/t/button-triggered-object-movement/11283/1 "2003-01-14T23:30:38Z")

</div>

alright i know i can tell a target to change it’s position on(press) of a button.

i would like to rewrite

```auto

on(mouseOver){
box._x+5;
}

```

so that you don’t have to keep putting the mouse on and off the button but you can just leave the mouse over the button and the object will move

i’m sure it’s a simple solution i’m just not thinking of at the moment, your help is greatly appreciated

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:** [January 14, 2003, 11:44pm UTC](https://forum.kirupa.com/t/button-triggered-object-movement/11283/2 "2003-01-14T23:44:25Z")

</div>

on(rollOver){  
if (!box.onEnterFrame) box.onEnterFrame = function(){this.\_x+=5;}  
}

on(rollOut){  
if (box.onEnterFrame) delete box.onEnterFrame;  
}

---

<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:** [January 15, 2003, 5:54pm UTC](https://forum.kirupa.com/t/button-triggered-object-movement/11283/3 "2003-01-15T17:54:47Z")

</div>

your script produces these errors

> 

Scene=main, Layer=buttons, Frame=1: Line 1: Invalid mouse event specified.  
on(mouseOver){

Scene=main, Layer=buttons, Frame=1: Line 2: Statement must appear within on handler  
if (!map.onEnterFrame) map.onEnterFrame = function(){this.\_x-=5;}

Scene=main, Layer=buttons, Frame=1: Line 3: Unexpected ‘}’ encountered  
}

please 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:** [January 15, 2003, 6:01pm UTC](https://forum.kirupa.com/t/button-triggered-object-movement/11283/4 "2003-01-15T18:01:42Z")

</div>

lol sorry

on(rollOver){  
if (!box.onEnterFrame) box.onEnterFrame = function(){this.\_x+=5;}  
}

on(rollOut){  
if (box.onEnterFrame) delete box.onEnterFrame;  
}

---

<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:** [January 15, 2003, 6:02pm UTC](https://forum.kirupa.com/t/button-triggered-object-movement/11283/5 "2003-01-15T18:02:56Z")

</div>

thank you very much =)
