# "movement using actionscript" prob

**URL:** https://forum.kirupa.com/t/movement-using-actionscript-prob/10483
**Category:** flash
**Created:** [January 2, 2003, 4:33am UTC](https://forum.kirupa.com/t/movement-using-actionscript-prob/10483 "2003-01-02T04:33:35Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![sk8erboi\_Q8](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@sk8erboi\_Q8](https://forum.kirupa.com/u/sk8erboi_Q8)
#### Post date: [January 2, 2003, 4:33am UTC](https://forum.kirupa.com/t/movement-using-actionscript-prob/10483/1 "2003-01-02T04:33:35Z")

</div>

I was reading the tutorial in this site about movement using actionscript, here is the url if any one wants it…

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

the tutorial is really amazing 🙂 the only thing i was wondering about is if it is possible to make the box (example used in url) stop at a certain point instead of just going further…  
i reaaallly would love to know if i can do that…! thank you and i i’d appreciate ne help 🙂

Happy New Year\<:}

---

<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 2, 2003, 4:37am UTC](https://forum.kirupa.com/t/movement-using-actionscript-prob/10483/2 "2003-01-02T04:37:03Z")

</div>

Yeah, you will need to declare in if statement for that.

That would go something like this…

```auto
onClipEvent(enterFrame) {
     speed = 1;
     this._x += speed;
<B>if(this._x>=200) {
this._x = 200;
}</B>
}

```

That says that if the \_x location of the clip is greater than or equal to 200 pixels then it should day at 200 pixels, hence… stopping it there 🙂

---

<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 2, 2003, 4:39am UTC](https://forum.kirupa.com/t/movement-using-actionscript-prob/10483/3 "2003-01-02T04:39:48Z")

</div>

wow!! it works 🙂  
thank you sooo much!! i didnt expect an answer soo fast, thanks again 🙂

cheers!

---

<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 2, 2003, 4:49am UTC](https://forum.kirupa.com/t/movement-using-actionscript-prob/10483/4 "2003-01-02T04:49:14Z")

</div>

No problem man 🙂

---

<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 2, 2003, 4:49am UTC](https://forum.kirupa.com/t/movement-using-actionscript-prob/10483/5 "2003-01-02T04:49:24Z")

</div>

i got one more question i’d like to ask if u dont mind! 🙂

u c lets say i have a rectangle and i assigned this AS to it…

onClipEvent(enterFrame) {  
speed = 100;  
this.\_x += speed;  
if(this.\_x\>=0) {  
this.\_x = 0;  
}  
}

and after it is done going to that place i’d want it to go down…  
i know that i havta change the \_x to \_y but what i mean is what do i do so that after it reaches the \_x destination then it starts to accomplish the \_y position…? its sounds confusing i know 😛  
thank u

---

<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 2, 2003, 5:11am UTC](https://forum.kirupa.com/t/movement-using-actionscript-prob/10483/6 "2003-01-02T05:11:18Z")

</div>

Something along the lines of…

```auto
onClipEvent (enterFrame) {
	speed = 5;
	this._x += speed;
	if (this._x>=200) {
		this._x = 200;
		this._y += speed;
		if (this._y>=200) {
			this._y = 200;
		}
	}
}

```

Where it reaches the \_x if statement, and then it executes the \_y movement while the clip is at 200 and it moves the block down to 200 then stops there.

---

<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 2, 2003, 5:17am UTC](https://forum.kirupa.com/t/movement-using-actionscript-prob/10483/7 "2003-01-02T05:17:12Z")

</div>

it worked 🙂 thanxs again man!

---

<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 2, 2003, 5:35am UTC](https://forum.kirupa.com/t/movement-using-actionscript-prob/10483/8 "2003-01-02T05:35:08Z")

</div>

No problem man.

---

<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 2, 2003, 3:03pm UTC](https://forum.kirupa.com/t/movement-using-actionscript-prob/10483/9 "2003-01-02T15:03:55Z")

</div>

Hey lost. Do these onEnterFrame commands still fire even if the mc reaches its defined x and y coordinates? I assume they do. Would you put an if statement in the code to delete the enterframe command? I’ve heard that saves CPU work.

---

<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 2, 2003, 5:17pm UTC](https://forum.kirupa.com/t/movement-using-actionscript-prob/10483/10 "2003-01-02T17:17:33Z")

</div>

Well moving one clip like that isn’t very CPU intensive, but yes, you can delete an onEnterFrame, but that would involve an onEnterFrame, not on onClipEvent(enterFrame).

So in that case the code above would become…

```auto
this.onEnterFrame = function {
	speed = 5;
	this._x += speed;
	if (this._x>=200) {
		this._x = 200;
		this._y += speed;
		if (this._y>=200) {
			this._y = 200;
                                delete this.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 2, 2003, 5:17pm UTC](https://forum.kirupa.com/t/movement-using-actionscript-prob/10483/11 "2003-01-02T17:17:33Z")

</div>

Well moving one clip like that isn’t very CPU intensive, but yes, you can delete an onEnterFrame, but that would involve an onEnterFrame, not on onClipEvent(enterFrame).

So in that case the code above would become…

```auto
this.onEnterFrame = function {
	speed = 5;
	this._x += speed;
	if (this._x>=200) {
		this._x = 200;
		this._y += speed;
		if (this._y>=200) {
			this._y = 200;
                        delete this.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 2, 2003, 9:58pm UTC](https://forum.kirupa.com/t/movement-using-actionscript-prob/10483/12 "2003-01-02T21:58:42Z")

</div>

man , just learn some basic programming , and then go intro ActionScript

if you know some bit of programming, Action Script becomes a very intuitive envoirement… my advice 🙂

---

<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 2, 2003, 10:26pm UTC](https://forum.kirupa.com/t/movement-using-actionscript-prob/10483/13 "2003-01-02T22:26:47Z")

</div>

People dont know that all the code lost gave us is AI  
Iv’e been studying that code for a wile now and could make a cirxcle go around a whole course.  
All you would need is that when a car hits it  
store last cordinates and make it move a couple digits away.

Well its really good code

---

<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 2, 2003, 10:32pm UTC](https://forum.kirupa.com/t/movement-using-actionscript-prob/10483/14 "2003-01-02T22:32:20Z")

</div>

Yeah, I don’t remember the last time I have ever used a tween though. All my motion is AS…lol.

Well, until I make my flash site, then I will be sure to need tweens somewhere…lol.

---

<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 3, 2003, 12:59am UTC](https://forum.kirupa.com/t/movement-using-actionscript-prob/10483/15 "2003-01-03T00:59:44Z")

</div>

Lostin Beta

I tried many times to see if i can get the Circle tomove in a circle course.

Doesent seem to work

The cod eyou gave me is the only part thast wokrs.  
Here is th code i have dont work right.

```auto
onClipEvent (enterFrame) {
    speed = 15;
    this._x += speed;
    if (this._x>=200) {
        this._x = 200;
        this._y += speed;
        if (this._y>=200) {
            this._y = 200;
            this._x -= speed;
            if (this._x>=200) {
                this._x = 200;
                this._x -= speed;
                if (this._x>=200) {
                    this._x = 200;
                    this._y += speed;
                    if (this._y>=200) {
                        this._x += speed;
                        if (this._x>=450) {
                            this._x = 450;
                        }
                    }
                }
            }
        }
    }
}

```

I hope you can 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 3, 2003, 1:00am UTC](https://forum.kirupa.com/t/movement-using-actionscript-prob/10483/16 "2003-01-03T01:00:35Z")

</div>

omg thats some insane nesting

---

<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 3, 2003, 3:29am UTC](https://forum.kirupa.com/t/movement-using-actionscript-prob/10483/17 "2003-01-03T03:29:30Z")

</div>

HOLY SHIZMATS!!!

Yeah, that is definitely some insane stuff there…lol.

---

<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 3, 2003, 5:06am UTC](https://forum.kirupa.com/t/movement-using-actionscript-prob/10483/18 "2003-01-03T05:06:27Z")

</div>

why arent you using the geometric formula for a circle to define the path - in place of the nesting nightmare you’ve created?😉

Peace
