# time dial rotation with actionscript in one frame

• babygodzilla
• Newbie
• Joined: Jan 13, 2004
• Posts: 7
• Status: Offline

January 13th, 2004, 12:43 pm

this was supposed to be simple but ionno why its turning out to be too complicated for me. I have a timer that should run after Button A is clicked. The timer has a dial that should rotate 360 degrees with a speed that I can modify before it head onto Action B. I can do this with tweening but I am asked to do it with Actionscript, in one frame. HELP PLEASE???

thx!!! bowdown.gif
• Anonymous
• Bot
• Joined: 25 Feb 2008
• Posts: ?
• Loc: Ozzuland
• Status: Online

January 13th, 2004, 12:43 pm

• lostinbeta
• Guru
• Joined: Jun 26, 2003
• Posts: 1402
• Status: Offline

January 13th, 2004, 9:52 pm

Something like this should probably work (untested)...
Code: [ Select ]
function spinDial(speed) {
this.rot = 0;
yourClip.onEnterFrame = function() {
this.rot += Math.floor(speed);
if (this.rot>=360) {
this.rot = 360;
delete this.onEnterFrame;
}
this._rotation = this.rot;
};
}
//useage example
spinDial(5);
1. function spinDial(speed) {
2.     this.rot = 0;
3.     yourClip.onEnterFrame = function() {
4.         this.rot += Math.floor(speed);
5.         if (this.rot>=360) {
6.             this.rot = 360;
7.             delete this.onEnterFrame;
8.         }
9.         this._rotation = this.rot;
10.     };
11. }
12. //useage example
13. spinDial(5);
In the above code "yourClip" is the instance name on the clip on your stage that is going to rotate. And the function to spin this clip is called "spinDial()" and it takes one argument... that argument is called speed, and it adjust how fast you want the spin to be.
• babygodzilla
• Newbie
• Joined: Jan 13, 2004
• Posts: 7
• Status: Offline

January 14th, 2004, 2:17 pm

thanks! i will try it soon!

i might have to make some mods tho, because Flash in some weird twisted away counts degrees starting from 0 to 180, and then from -170 back to 0... ionno why that baffles me too. that's actually one of the problems im having
• lostinbeta
• Guru
• Joined: Jun 26, 2003
• Posts: 1402
• Status: Offline

January 14th, 2004, 4:04 pm

Yes I am aware of that little ditty, 'tis why I incremented the rot variable and not the _rotation property... that way I could accurately check the value of the variable

I just tested it, it works pretty good, although i'm sure theres some better method out there that uses some radians to degrees method... I don't have time to figure all that jazz out though
• babygodzilla
• Newbie
• Joined: Jan 13, 2004
• Posts: 7
• Status: Offline

January 15th, 2004, 2:23 pm

good stuff man! its almost working correctly, cept for some reason the dial starts at the bottom (6 oclock position) after i click the button, andi just have to synchronize it with the rest of my movie. thx!!

## Post Information

• Total Posts in this topic: 5 posts
• Users browsing this forum: No registered users and 45 guests
• You cannot post new topics in this forum
• You cannot reply to topics in this forum
• You cannot edit your posts in this forum
• You cannot delete your posts in this forum
• You cannot post attachments in this forum

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.