# \[mx\] In need of a/s brilliance

**URL:** <https://forum.kirupa.com/t/mx-in-need-of-a-s-brilliance/15057>\
**Category:** Uncategorized\
**Created:** [March 10, 2003, 3:22pm UTC](https://forum.kirupa.com/t/mx-in-need-of-a-s-brilliance/15057 "2003-03-10T15:22:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lacuna](https://avatars.discourse-cdn.com/v4/letter/l/edb3f5/32.png) [@Lacuna](https://forum.kirupa.com/u/Lacuna)\
**Post date:** [March 10, 2003, 3:22pm UTC](https://forum.kirupa.com/t/mx-in-need-of-a-s-brilliance/15057/1 "2003-03-10T15:22:35Z")

</div>

[size=1]I had this post in the flash mx section but once it came down to studying the code I got no replies so i’ll post my question here now instead[/size]

My random movement works file when on \_root but I have it loading on level18 now. I have changed the code accordingly (all \_root to \_level18) but it still leaves the boundary.

Here’s the code in the \_level18 file

```php

function getdistance(x, y, x1, y1) {
	var run, rise;
	run = x1-x;
	rise = y1-y;
	return (_level18.hyp(run, rise));
}
function hyp(a, b) {
	return (Math.sqrt(a*a+b*b));
}
MovieClip.prototype.reset = function() {
	// specify the width and height of the movie
	width = 685;
	height = 57;
	// -------------------
	var dist, norm;
	this.x = this._x;
	this.y = this._y;
	this.speed = Math.random()*4+2;
	this.targx = Math.random()*width;
	this.targy = Math.random()*height;
	dist = _level18.getdistance(this.x, this.y, this.targx, this.targy);
	norm = this.speed/dist;
	this.diffx = (this.targx-this.x)*norm;
	this.diffy = (this.targy-this.y)*norm;
};
MovieClip.prototype.move = function() {
	if (_level18.getdistance(this.x, this.y, this.targx, this.targy)>this.speed) {
		this.x += this.diffx;
		this.y += this.diffy;
	} else {
		this.x = this.targx;
		this.y = this.targy;
		if (!this.t) {
			this.t = getTimer();
		}
		if (getTimer()-this.t>1000) {
			this.reset();
			this.t = 0;
		}
	}
	this._x = this.x;
	this._y = this.y;
};

```

THANK-YOU for ANY help guys. This one is a total maze to me.

:love: ~ Seretha

p.s. Yea GuigO this is the same post, I tried to post my fla but it took a really long time and then when it finally finished it wasn’t even 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:** [March 10, 2003, 8:33pm UTC](https://forum.kirupa.com/t/mx-in-need-of-a-s-brilliance/15057/2 "2003-03-10T20:33:47Z")

</div>

I think it looks pretty cool as it is, and I’m not sure there’s an easy way to solve that (especially because all the clips don’t have the same size…).

pom :-\

---

<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 10, 2003, 8:37pm UTC](https://forum.kirupa.com/t/mx-in-need-of-a-s-brilliance/15057/3 "2003-03-10T20:37:14Z")

</div>

It doesn’t leave the boundary?

Keep in mind the location is represented by the registration point of the clip, not the edge of the clip. So the registration point is definitely staying within the right area.

And as Ilyas said, considering the different sizes of your clips, there is no easy way of fixing that problem being the math will be different for each and every clip.

---

<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 10, 2003, 8:40pm UTC](https://forum.kirupa.com/t/mx-in-need-of-a-s-brilliance/15057/4 "2003-03-10T20:40:16Z")

</div>

remove the \_level18. from that piece of code:

```auto

return (_level18.hyp(run, rise));

```

it should look like that now

```auto

return (hyp(run, rise));

```

i tested, and it worked fer me 😉

Cheers :bouce:
