Freely Rotate Objects

Hello Everyone :beam:

I’ve been working on a flash animation and have become stuck. :*(

I have objects that are draggable, but I would like to put in a control to freely rotate the object. I had assigned individual buttons to each object so that when they are pressed, the object will face in that direction, although I would like to add a key on the object that can be used to rotate it around its center.

Does anybody know a way to accomplish this? Your help would be greatly appreciated.

-Ashley

Well if you don’t mind using components to do it you can find a couple that do exactly that at http://www.flashcomponents.net/

if I get you right… use


// for on the movieclip
on(press){
	dragging = true;
	orig_mouse_angle = Math.atan2(_parent._ymouse-_y, _parent._xmouse-_x) * 180/Math.PI;
	orig_rotation = _rotation;
}
on(release,releaseOutside){
	dragging = false;
}
onClipEvent(mouseMove){
	if(dragging){
		curr_mouse_angle = (Math.atan2(_parent._ymouse-_y, _parent._xmouse-_x) * 180/Math.PI)
		_rotation = orig_rotation + curr_mouse_angle - orig_mouse_angle;
		updateAfterEvent()
	}
}

or


// from the timeline
clip.onPress = function(){
	this.dragging = true;
	this.orig_mouse_angle = Math.atan2(this._parent._ymouse-this._y, this._parent._xmouse-this._x) * 180/Math.PI;
	this.orig_rotation = this._rotation;
}
clip.onRelease = clip.onReleaseOutside = function(){
	this.dragging = false;
}
clip.onMouseMove = function(){
	if(this.dragging){
		var curr_mouse_angle = (Math.atan2(this._parent._ymouse-this._y, this._parent._xmouse-this._x) * 180/Math.PI)
		this._rotation = this.orig_rotation + curr_mouse_angle - this.orig_mouse_angle;
		updateAfterEvent();
	}
}