time dial rotation with actionscript in one frame

  • babygodzilla
  • Newbie
  • Newbie
  • babygodzilla
  • Posts: 7

Post 3+ Months Ago

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
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

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
  • Newbie
  • babygodzilla
  • Posts: 7

Post 3+ Months Ago

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
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

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
  • Newbie
  • babygodzilla
  • Posts: 7

Post 3+ Months Ago

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 3 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.