Random.... teddy bear movement!

at vmkdsn.com!

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

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):

// 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:

// 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.

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

lol… it’s my style :stuck_out_tongue:

sezier