All pastes #740586 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-10-18 01:20 UTC
rendered paste body
//quereys mouse x and y locations, translates to radian location (based on arrow center), translates to degrees and applys as rotational value of arrow
	var myAngleR:Number = Math.atan2(_root._xmouse-arrowGo._x, _root._ymouse-arrowGo._y);
	var myAngleD:Number = myAngleR * (180 / Math.PI);

function arrowFollow() {
	myAngleR = Math.atan2(_root._xmouse-arrowGo._x, _root._ymouse-arrowGo._y);
	myAngleD = myAngleR * (180 / Math.PI);
	trace (myAngleR);
	
	arrowGo._rotation = -myAngleD + 90;
}

_root.onEnterFrame = arrowSwing()

function arrowSwing() {
	arrowGo._rotation = Math.cos(myAngleR)* 160;
	trace (myAngleR);
	myAngleR += .1;
}
	

var mouseListener:Object = new Object;

//if mouse is pressed, runs arrowFollow function
mouseListener.onMouseDown = function(){
	_root.arrowFollow();
	_root.onMouseMove = _root.arrowFollow;
}

//if mouse is released, kills move function
mouseListener.onMouseUp = function(){
	delete _root.onMouseMove;
	_root.onEnterFrame = arrowSwing;
}

Mouse.addListener(mouseListener);