# \[mx\] D@mn Random Circles givin me a headache!

**URL:** <https://forum.kirupa.com/t/mx-d-mn-random-circles-givin-me-a-headache/15770>\
**Category:** flash\
**Created:** [March 17, 2003, 11:53pm UTC](https://forum.kirupa.com/t/mx-d-mn-random-circles-givin-me-a-headache/15770 "2003-03-17T23:53:17Z")\
**Posts on this page:** 7\
**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 17, 2003, 11:53pm UTC](https://forum.kirupa.com/t/mx-d-mn-random-circles-givin-me-a-headache/15770/1 "2003-03-17T23:53:17Z")

</div>

Hey. I am using the random circle tutorial on my main page  
[http://www.cyberwebs.org](http://www.cyberwebs.org) but the .swf I made that I’ve imported into that site is from  
[http://www.cyberwebs.org](http://www.cyberwebs.org)  
See how the .swf cuts off the cirlces when it goes past the boundary? Why won’t it do that on my site?

Here is the a/s

```php
// special thanks to Suprabeener for the code
function getdistance(x, y, x1, y1) {
	var run, rise;
	run = x1-x;
	rise = y1-y;
	return (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 = 10;
	// -------------------
	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 = _root.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 (_root.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;
};

```

I’ve tried changing the \_‘root’ codes to \_level15 (the level they are being loaded into…but it still doesn’t stay in the boundaries? Anyone have any suggestions?? This thing is giving me a headache!

:love:

---

<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 18, 2003, 12:00am UTC](https://forum.kirupa.com/t/mx-d-mn-random-circles-givin-me-a-headache/15770/2 "2003-03-18T00:00:29Z")

</div>

I answered this last time you asked it :-\

It is because the position goes by the registration point of the clip, not the edges of the 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 18, 2003, 12:02am UTC](https://forum.kirupa.com/t/mx-d-mn-random-circles-givin-me-a-headache/15770/3 "2003-03-18T00:02:20Z")

</div>

I think I’ve seen that question before :trout:

Try that:

```auto
    this.targx = Math.random()*(width-20)+10;
    this.targy = Math.random()*(height-20)+10;

```

It _might_ 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:** [March 18, 2003, 12:10am UTC](https://forum.kirupa.com/t/mx-d-mn-random-circles-givin-me-a-headache/15770/4 "2003-03-18T00:10:27Z")

</div>

lost - the registration point in the little swf are on every single little circle and the reg point in my main movie is centered in the top space…

ilya- nope…still outside boundaries…

---

<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 18, 2003, 12:12am UTC](https://forum.kirupa.com/t/mx-d-mn-random-circles-givin-me-a-headache/15770/5 "2003-03-18T00:12:07Z")

</div>

i heard somewhere i can load html into flash…would that work if i imported this as an html (seeing as it looks great as an html by itself) or will it not work that way…

---

<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 18, 2003, 12:16am UTC](https://forum.kirupa.com/t/mx-d-mn-random-circles-givin-me-a-headache/15770/6 "2003-03-18T00:16:31Z")

</div>

You can’t load HTML files into Flash, you can only load HTML formatted text into it.

And the only thing that matters it the registration point of the clip that is moving.

It seems you have it in the middle of the circle. That means that any part of the clip will be able to go out of bounds except for the middle part because that is where the registration point is. You will have to change your area that clips move around in.

---

<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 18, 2003, 12:35am UTC](https://forum.kirupa.com/t/mx-d-mn-random-circles-givin-me-a-headache/15770/7 "2003-03-18T00:35:29Z")

</div>

hmmm…that seems like it should be the problem. Thanks LostinBeta!!! I’ll let you know how it goes!

:love:
