# 3d rotate with mouseDown?

**URL:** <https://forum.kirupa.com/t/3d-rotate-with-mousedown/215715>\
**Category:** flash\
**Created:** [February 9, 2007, 5:33pm UTC](https://forum.kirupa.com/t/3d-rotate-with-mousedown/215715 "2007-02-09T17:33:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaplanyo](https://avatars.discourse-cdn.com/v4/letter/k/35a633/32.png) [@kaplanyo](https://forum.kirupa.com/u/kaplanyo)\
**Post date:** [February 9, 2007, 5:33pm UTC](https://forum.kirupa.com/t/3d-rotate-with-mousedown/215715/1 "2007-02-09T17:33:08Z")

</div>

I’ve got this ball that rotates around a center and I see how the speed changes with a number or with the location of the mouse, but I’d like to have the ball just rotate until the user does a mouseDown … then they can spin the ball by moving left or right. like a QTVR kinda thing… Any suggestions?

Here’s what I’ve hobbled together so far.

```auto
var fl:Number = 150;
var vpX:Number = Stage.width / 2;
var vpY:Number = Stage.height / 2;

init();
function init() {
		ball.x = 0;
		ball.y = 0;
		ball.z = 100;
}

function onEnterFrame():Void {
		
		var angleY:Number = .2; // (_xmouse - vpX) * .001;
		var cosY:Number = Math.cos(angleY);
		var sinY:Number = Math.sin(angleY);
		
		var x1:Number = ball.x * cosY - ball.z * sinY;
		var z1:Number = ball.z * cosY + ball.x * sinY;
		
		ball.x = x1;
		ball.z = z1;

		var scale:Number = fl / (fl + ball.z);
		ball._xscale = ball._yscale = scale*100;
		ball._x = vpX + ball.x * scale;
		ball._y = vpY + ball.y * scale;
	}

```
