There is a tutorial here on “Spinning Panes”
http://www.kirupa.com/developer/actionscript/camera_panning.htm
The objects spin around y-axis.
The spin of the objects is based on mouse position, the more you move your mouse to one side the faster it spins. ( spin -= this._xmouse/1000; ).
My question is how do i get the objects to stop spinning when I move the mouse outside a certain region, like ( this._xmouse > 200 ).
But I don’t want the objects to just stop spinning, I want them to stop spinning gradually, as if they had inertia.
I don’t know how to do this, I was thinking ( setInterval ) or maybe one of the ( mx.transitions ) but I have no idea how to implement any of this.
Thank you for your help.
Here is the full code from the tutorial :
this.createEmptyMovieClip(“theScene”, 1);
theScene._x = 150;
theScene._y = 100;
objectsInScene = new Array();
focalLength = 500;
spin = 0;
displayPane = function(){
var angle = this.angle + spin;
var x = Math.cos(angle)*this.radius;
var z = Math.sin(angle)*this.radius;
var y = this.y;
var scaleRatio = focalLength/(focalLength + z);
this._x = x * scaleRatio;
this._y = y * scaleRatio;
this._xscale = this._yscale = 100 * scaleRatio;
this._xscale *= Math.sin(angle);
this.swapDepths(Math.round(-z));
};
angleStep = 2*Math.PI/8;
for (i=0; i < 8; i++){
attachedObj = theScene.attachMovie(“pane”, “pane”+i, i);
attachedObj.angle = angleStep * i;
attachedObj.radius = 100;
attachedObj.x = Math.cos(attachedObj.angle) * attachedObj.radius;
attachedObj.z = Math.sin(attachedObj.angle) * attachedObj.radius;
attachedObj.y = 40;
attachedObj.display = displayPane;
objectsInScene.push(attachedObj);
}
panCamera = function(){
spin -= this._xmouse/1000;
for (var i=0; i < objectsInScene.length; i++){
objectsInScene*.display();
}
};
theScene.onEnterFrame = panCamera;