# Movement with actionscript in flash

**URL:** https://forum.kirupa.com/t/movement-with-actionscript-in-flash/16617
**Category:** Uncategorized
**Created:** [March 26, 2003, 9:25pm UTC](https://forum.kirupa.com/t/movement-with-actionscript-in-flash/16617 "2003-03-26T21:25:06Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![mikeyb](https://avatars.discourse-cdn.com/v4/letter/m/edb3f5/32.png) [@mikeyb](https://forum.kirupa.com/u/mikeyb)
#### Post date: [March 26, 2003, 9:25pm UTC](https://forum.kirupa.com/t/movement-with-actionscript-in-flash/16617/1 "2003-03-26T21:25:06Z")

</div>

Ok, I recently got intrested in flash and now want to increase my flash ability with actionscript,

I have Flash MX and am wondering how with action script i can move a symbol or movieclip when clicking on a button with the use of actionscript. I want to be able to to move a symbol or movieclip to an exact location and with some animation like a motion tween but with the use of actionscript.

Can anyone shed any light on the subject , I really need help and am looking for any suggestions.

---

<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 27, 2003, 4:18am UTC](https://forum.kirupa.com/t/movement-with-actionscript-in-flash/16617/2 "2003-03-27T04:18:22Z")

</div>

mikey,

check out this tutorial on Kirupa to find out more:

[http://www.kirupa.com/developer/mx/ASmovement.htm](http://www.kirupa.com/developer/mx/ASmovement.htm)

if that doesn’t help, post your questions on here and i’ll be sure to answer 🙂

---

<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 27, 2003, 5:34pm UTC](https://forum.kirupa.com/t/movement-with-actionscript-in-flash/16617/3 "2003-03-27T17:34:10Z")

</div>

yes that was helpful but how can i make the symbol or movieclip stop and start at a specific location,  
such as starting at x 50 y 50 and finishing at x 50 y 100 ?  
please reply and  
thankyou

---

<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 27, 2003, 5:49pm UTC](https://forum.kirupa.com/t/movement-with-actionscript-in-flash/16617/4 "2003-03-27T17:49:26Z")

</div>

put it at x50 and y50, then

```auto
onClipEvent(enterFrame) {
     speed = 5;
     if(this._y<100){
          this._y += speed;
     }
}

```

untested, see if that works

---

<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 27, 2003, 5:56pm UTC](https://forum.kirupa.com/t/movement-with-actionscript-in-flash/16617/5 "2003-03-27T17:56:54Z")

</div>

morse u rule !!!  
if i need any more help ur the one to try  
thanx  
mike

---

<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 27, 2003, 6:02pm UTC](https://forum.kirupa.com/t/movement-with-actionscript-in-flash/16617/6 "2003-03-27T18:02:11Z")

</div>

🙂 Thanks man. I’m nothing compaired to most of the people on this site.

Anyway, if you have any questions, feel free to PM me, or email me: [himself@morsedesigns.com](mailto:himself@morsedesigns.com)

---

<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 27, 2003, 6:02pm UTC](https://forum.kirupa.com/t/movement-with-actionscript-in-flash/16617/7 "2003-03-27T18:02:49Z")

</div>

ooh  
one more question how can i make it start moving from where it was so it can move up and down with the use of a button? and when u click another button it starts from where it was and goes to a new location

thanx for your help  
mike

---

<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 27, 2003, 6:07pm UTC](https://forum.kirupa.com/t/movement-with-actionscript-in-flash/16617/8 "2003-03-27T18:07:37Z")

</div>

On the stage make two buttons. One above the other. Call the top one (using instance names) “MCup” and the bottom one “MCdown” (both without quotes). On the stage name the thing you want to move (using instance names) “myMC”.

```auto
//Code for the top button - MCup
on(release){
     _root.myMC._y+=5
}

```

```auto
//Code for the bottom button - MCdown
on(release){
     _root.myMC._y-=5
}

```

untested, see if it works

---

<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 27, 2003, 9:23pm UTC](https://forum.kirupa.com/t/movement-with-actionscript-in-flash/16617/9 "2003-03-27T21:23:32Z")

</div>

ok thAT WAS ALMOST WHAT I WANTED BUTi wanted to be able to move the button continuously from point to point with only one click of the button and it move to a specific location like with the  
previous example instead of stopping every 5 pixels  
is this possible

thanx mike

---

<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 27, 2003, 10:35pm UTC](https://forum.kirupa.com/t/movement-with-actionscript-in-flash/16617/10 "2003-03-27T22:35:06Z")

</div>

I’v been meaning to try this… Here’s my chance 🙂  
Try this. In the first frame of the timeline put this:

```auto
MovieClip.prototype.move = function() {
	speed = 25;
	endX = 200;//Final X position you want
	endY = 200;//Final Y Position you want
	this._x += (endX-this._x)/speed;
	this._y += (endY-this._y)/speed;
};

```

on the movie clip that is to move (myMC) put this:

```auto
onClipEvent(enterFrame){
     move()
}

```

---

<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 28, 2003, 4:55am UTC](https://forum.kirupa.com/t/movement-with-actionscript-in-flash/16617/11 "2003-03-28T04:55:01Z")

</div>

The cool thing is that you could change the endx and endy values to variables and then change them when a button is pushed, and the thing will automatically move.

---

<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 28, 2003, 5:14am UTC](https://forum.kirupa.com/t/movement-with-actionscript-in-flash/16617/12 "2003-03-28T05:14:04Z")

</div>

I think.

---

<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 29, 2003, 6:58pm UTC](https://forum.kirupa.com/t/movement-with-actionscript-in-flash/16617/13 "2003-03-29T18:58:45Z")

</div>

HOW CAN I CHANGE THE endy and endx to VARIABLES and make them change when a button is pressed sorry im a bit new at this your help is much aprecated  
thanx  
mike
