Hey guys!
I need some help in transforming a script from AS 2.0 to AS 3.0. I’m busy for school making some small game in which I use a spinning wheel. I really like this script, only it’s written in AS 2.0. Can anyone help me transform this into AS 3.0? I’d really appreciate it!
[FONT=monospace]
[LIST=1]
[]damp = .96; //friction
[]r = 0; //rotation
[]accr = 0; //speed of rotation
[]
[]knob.onPress = function() {
[]dragging = true;
[]//find mouse y coordinate in relation to knob origin
[]a = _root._ymouse - knob._y;
[]//find mouse x coordinate in relation to knob origin
[]b = _root._xmouse - knob._x;
[]//using arctangent find the spot of rotation (in degrees)
[]oldr = Math.atan2(a,b)180/Math.PI;
[]}
[]
[]knob.onRelease = knob.onReleaseOutside = function() {
[]dragging = false;
[]}
[]
[]knob.onEnterFrame = function() {
[]if (dragging) {
[]//find mouse y coordinate in relation to knob origin
[]a = _root._ymouse-knob._y;
[]//find mouse x coordinate in relation to knob origin
[]b = _root._xmouse-knob._x;
[]//using arctangent find the spot of rotation (in degrees)
[]r = Math.atan2(a,b)180/Math.PI;
[]
[]//use current rotation and previous rotation
[]//to find acceleration
[]//averages the acceleration with the
[]//previous acceleration for smoother spins
[]accr = ((r - oldr) + accr)/2;
[]//apply the acceleration to the rotation
[]knob._rotation += accr;
[]//remember current rotation as old rotation
[]oldr = r;
[]feedbacka.text = a;
[]feedbackb.text = b;
[]}
[]else {
[]knob._rotation += accr;
[]//apply friction to acceleration force
[]//and if acceleration gets tiny, just set it to zero
[]if (Math.pow(accr, 2) > .0001 ) {
[]accr = damp;
[]}
[]else{
[]accr = 0;
[]}
[]}
[]//spit out feedback continuosly
[]feedbackr.text = knob._rotation;
[]feedbackaccr.text = accr;
[*]}
[/LIST]
[/FONT]