PDA

View Full Version : Easing Rotation


rustybones
06-28-2004, 01:01 AM
Hey guys, I've been scouring through these forums for the past hour or so with no joy so heres the problem:

I'm basically creating a turntable in flash. Now I'm using this code :


onClipEvent(enterFrame) {
this._rotation += 8;
}


on the MC that I want to rotate. Now what I need to do is when the user presses the "off" buttons the record slows down to a stop. It should be pretty simple but hey, I'm a dumbarse! :(

senocular
06-28-2004, 01:23 AM
http://www.senocular.com/downloads/index.php?subaction=showfull&id=1074709074&archive=&start_from=&ucat=2&kind=2

rustybones
06-28-2004, 01:43 AM
Hey thanks for that, thats pretty much what I"m after, except with the start and stopping on a button and for the disc to start spinning as soon as it enters the frame...

Sorry to be a hassle :)

pixelwit
06-28-2004, 04:19 AM
stopFactor = .9;
startFactor = 1.1;
minSpeed = .1;
maxSpeed = 30;
speed = maxSpeed;
//
function spin(){
this._rotation += speed;
}
function stopSpinning (){
speed *= stopFactor;
this._rotation += speed;
if(speed < minSpeed){
speed = minSpeed;
delete this.onEnterFrame;
trace("stopped spinning");
}
}
function startSpinning (){
speed *= startFactor;
this._rotation += speed;
if(speed > maxSpeed){
speed = maxSpeed;
this.onEnterFrame = spin;
trace("spinning at full speed");
}
}
//
// You need 3 clips on stage
// Spinner, StopButton and StartButton
Spinner.onEnterFrame = spin;
StopButton.onRelease = function(){
Spinner.onEnterFrame = stopSpinning;
}
StartButton.onRelease = function (){
if(speed<1) speed = 1;
Spinner.onEnterFrame = startSpinning;
}

-PiXELWiT
http://www.pixelwit.com

rustybones
06-28-2004, 04:43 AM
cool, that starts it, but it does'nt stop (and yes i have named a button StopButton) :(

pixelwit
06-28-2004, 04:51 AM
File attached.

-PiXELWiT
http://www.pixelwit.com

rustybones
06-28-2004, 05:00 AM
okay disregard that last post...it seems to be working....just had to work the timeline around the code....only thing is what do i do if I want the stop/start buttons to be the same button?

pixelwit
06-28-2004, 05:36 AM
File attached.

-PiXELWiT
http://www.pixelwit.com

rustybones
06-28-2004, 05:44 AM
pixelwit did I ever tell you - you're my hero! thank you so much. I've read lots of posts from you that have helped my learning in flash greatly. Thanks for all your help!

pixelwit
06-28-2004, 06:06 AM
You're welcome and thanks for the compliment.

-PiXELWiT
http://www.pixelwit.com

Thylacine
07-06-2005, 06:25 AM
Sorry to re-open an old post, but this is just what I wanted! Thank-you!

pixelwit
07-08-2005, 08:39 PM
No problem.

Thanks for the thanks.

-PiXELWiT
http://www.pixelwit.com