# Need to update a 'Spinning Wheel' script from AS 2.0 to AS 3.0

**URL:** <https://forum.kirupa.com/t/need-to-update-a-spinning-wheel-script-from-as-2-0-to-as-3-0/277669>\
**Category:** Uncategorized\
**Created:** [December 15, 2008, 6:21pm UTC](https://forum.kirupa.com/t/need-to-update-a-spinning-wheel-script-from-as-2-0-to-as-3-0/277669 "2008-12-15T18:21:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jashan](https://avatars.discourse-cdn.com/v4/letter/j/f08c70/32.png) [@Jashan](https://forum.kirupa.com/u/Jashan)\
**Post date:** [December 15, 2008, 6:21pm UTC](https://forum.kirupa.com/t/need-to-update-a-spinning-wheel-script-from-as-2-0-to-as-3-0/277669/1 "2008-12-15T18:21:43Z")

</div>

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]
