# Random.... teddy bear movement!

**URL:** <https://forum.kirupa.com/t/random-teddy-bear-movement/22887>\
**Category:** Uncategorized\
**Created:** [June 10, 2003, 5:04am UTC](https://forum.kirupa.com/t/random-teddy-bear-movement/22887 "2003-06-10T05:04:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![liam](https://avatars.discourse-cdn.com/v4/letter/l/b9e5f3/32.png) [@liam](https://forum.kirupa.com/u/liam)\
**Post date:** [June 10, 2003, 5:04am UTC](https://forum.kirupa.com/t/random-teddy-bear-movement/22887/1 "2003-06-10T05:04:09Z")

</div>

at [vmkdsn.com](http://www.vmkdsn.com)!

you see what i’ve had to resort to since the random splash thing didn’t fly??? haha…

---

<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:** [June 10, 2003, 5:10am UTC](https://forum.kirupa.com/t/random-teddy-bear-movement/22887/2 "2003-06-10T05:10:35Z")

</div>

oh, and in case you’re interested:

set up a bounding box (rectangular movie clip) on your stage where you want the teddies to mosh around in.

then, on a frame of the root timeline, set up the coordinates of the bounding box with (where boundingBox\_mc is its instance name):

```auto
// define boundingBox's coordinates
boundLeft = boundingBox_mc._x;
boundRight = boundingBox_mc._x+boundingBox_mc._width;
boundTop = boundingBox_mc._y;
boundBottom = boundingBox_mc._y+boundingBox_mc._height;

```

then on the first frame of your bear movie clip:

```auto
// start jumping
randomMove = 50;

this.onEnterFrame = function(){
	//init xpos movements
	newXpos = this._x+(random(randomMove)-(randomMove/2));
	curXpos = this._x;
	if(curXpos<=_root.boundLeft){
		newXpos += random(randomMove);
	}else{
		if(curXpos>=_root.boundRight){
			newXpos += -(random(randomMove));
		}
	}
	//init ypos movements
	newYpos = this._y+(random(randomMove)-(randomMove/2));
	curYpos = this._y;
	if(curYpos<=_root.boundTop){
		newYpos += random(randomMove);
	}else{
		if(curYpos>=_root.boundBottom){
			newYpos += -(random(randomMove));
		}
	}
	// start moving
	this._x = newXpos;
	this._y = newYpos;
}

```

mosh, teddies, mosh.

---

<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:** [June 10, 2003, 5:11am UTC](https://forum.kirupa.com/t/random-teddy-bear-movement/22887/3 "2003-06-10T05:11:41Z")

</div>

hehe, but why you chose teddy bears is beyond me.

---

<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:** [June 10, 2003, 6:25am UTC](https://forum.kirupa.com/t/random-teddy-bear-movement/22887/4 "2003-06-10T06:25:18Z")

</div>

lol… it’s my style 😛

---

<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:** [June 10, 2003, 6:29am UTC](https://forum.kirupa.com/t/random-teddy-bear-movement/22887/5 "2003-06-10T06:29:17Z")

</div>

sezier
