hi there, i have a movie clip of a cd, and i want it to start spinning as if it were playing in a cd player?
how would i go about making it start off spinning slow then getting faster and then continue at a steady rate?
Printable View
hi there, i have a movie clip of a cd, and i want it to start spinning as if it were playing in a cd player?
how would i go about making it start off spinning slow then getting faster and then continue at a steady rate?
i=0;
_root.mc.onEnterFrame=function(){
i++;
this._rotation =i;
}
Here's a version that has a controllable acceleration.
code:
// set this to maximum desired rate
_root.mc.maxRate = 20;
// set this to control the initial acceleration
_root.mc.accel = 0.5;
_root.mc.curRate = 0;
_root.mc.onEnterFrame=function()
{
if (this.curRate < this.maxRate)
{
this.curRate += this.accel;
}
this._rotation += this.curRate;
}
Hi....
This will speed it up gradually......(this._rotation + = i;)
code:
i = 0;
_root.mc.onEnterFrame = function() {
i++;
this._rotation + = i;
};
all the above will work but jbum's one will work the best, why? simple the other two will keep increasing i to infinity, meaning that the illusion of the cd spinning up will also have the same illusion as it spinning down (when it gets past a certain speed) and also the illusion of it spinning backwards as well will happen.
yeah i used jbum's.
now, im wondering, if i have it spinning like it is, how can i get it to decrease to a stop as if someone pressed the stop button back to the original position?
thanks
Well the answer is infront of your face really, just need to understand how the if loop works, but here is the answer for you based on jbums code...
code:
// set this to maximum desired rate
_root.mc.maxRate = 0;
// set this to control the initial acceleration
_root.mc.accel = 0.5;
_root.mc.curRate = 20;
_root.mc.onEnterFrame=function()
{
if (this.curRate > this.maxRate)
{
this.curRate -= this.accel;
}
this._rotation -= this.curRate;
}
how does it work? simple, if the value of this.curRate is greater than the value of this.maxRate it tells curRate to decrease by the acceleration rate (this.curRate -= this.accel;)
it then tells the object to rotate by that amount
(this._rotation -= this.curRate;)
hope that answers your question and better understands the flash code as well
Quote:
Originally posted by notaloserflash
yeah i used jbum's.
now, im wondering, if i have it spinning like it is, how can i get it to decrease to a stop as if someone pressed the stop button?
yeah that works, but theres a couple problems
first, it spins the opposite direction when slowing down, and second, it doesnt stop in the original position..
is it possible to get it to stop in the original position?
thanks
actually dont worry about the spinning the wrong way, i just changed this._rotation -= this.curRate; to this._rotation += this.curRate;
but about the stopping in the original position? is that possible?
Well the code I gave you with your little change should have worked!... ack actually no it wouldnt have cause you are not reversing the cd rotation..
basicly to correct the problem you would have to do somet like this...
have the rotation speed go to a point where it rotates the cd so that it is at 180 degrees once it gets to its top speed, then decrease it at the same rate. That way it will stop at the same point it started at. Chances are there is an easier way than working out the algebra formula, jbum can you leand any insight??
I think the algebra equation would be (bear in mind I aint touched algebra for like 8 years... gosh thats a long time since the good old days :'( )
rotation = degree + (degree /2)
actually i know that is wrong just cant be arsed to delete it lol
rotation += degree, ...
oh well I am tired tis 5 in the morning, i hate night shifts :'(
Quote:
Originally posted by notaloserflash
actually dont worry about the spinning the wrong way, i just changed this._rotation -= this.curRate; to this._rotation += this.curRate;
but about the stopping in the original position? is that possible?
is there a way to just take it at the speed it goes at when its slowing down, then stay at a slow speed until it reaches the original position and stops there? like, a stop on original mc or something?
notalower - your correction makes sense. You want to keep spinning in the same direction, but the rate of change in the spin comes down.
Now to answer your last question, how to stop at a particular spot...
Lemme noodle on this one...
[edit]
Mebbe something like this? This won't look all that natural, but it does what you described.
I'm assuming the stopping position is _rotation == 0.
code:
// set this to slowest (final) speed
_root.mc.minRate = 1;
// set this to control the initial acceleration
_root.mc.deccel = 0.5;
_root.mc.curRate = 20;
_root.mc.onEnterFrame=function()
{
// slow down until we hit a speed of 1
if (this.curRate > this.minRate)
{
this.curRate -= this.deccel;
}
this._rotation += this.curRate;
// are we there yet?
if (Math.round(this._rotation) == 0)
{
// yep, we're there.
this._rotation = 0;
delete this.onEnterFrame;
}
}
That reminds me, on an unrelated discussion, a few days ago, (somebody asked me how to do moire patterns), I came across a technique that replicates the 'shiny' pattern on a CD, somewhat:
http://www.krazydad.com/bestiary/moire2.html
This is produced by the interference pattern between two sets of concentric rings.
Very nice moire pattern, could be adapted to a cd pattern as well so would be very nice. But i still think a simple fade would work better
Quote:
Originally posted by jbum
That reminds me, on an unrelated discussion, a few days ago, (somebody asked me how to do moire patterns), I came across a technique that replicates the 'shiny' pattern on a CD, somewhat:
http://www.krazydad.com/bestiary/moire2.html
This is produced by the interference pattern between two sets of concentric rings.
jbum - that is a pretty cool pattern, but its the top face of the cd and it has a label
i actually used a high def scanner and scanned the cd, but anyway
im changing the final speed of the script you gave me to stop it at a speed and continue at that speed until it reaches rotation 0, but only some values it will stop on rotation 0, i have only found that 1 works all the time, but i want it faster than that, otherwise it keeps spinning forever... i might be missing something, but i cant figure it out.. any ideas?
Depending on the values you choose, it may be skipping over 0 without _rotation ever being exactly equal to 0. You can deal with by changing this line:
if (Math.round(this._rotation) == 0)
to this:
if (Math.floor(Math.abs(this._rotation)) < 1)
Which stops it from spinning if the rotation is near zero. If the 'slow' speed is too high, then you may need to change the '1' to a higher number to get it to stop.
- Jim
ehr that gets it to stop in the right place, but it doesnt do the slowing down
instead of slowly decreasing to speed x then going to the rotation < 1 at speed x, it is just spinning until it hits < 1 without the decrease in speed.
it just does a full rotation until it is at a rotation < 1
do i need to do something like
if speed traveling at is "x" then ask the question
if (Math.round(this._rotation) < 1 )
?
instead of just telling it to decrease the speed and ask for when it is < 1 at the same time?
just trying to think of possibilities,
thanks,
nota
edit** lol i have been trying this, and i did this
if (this.curRate == this.minRate) {
if (Math.round(this._rotation) < 1 )
{
// yep, we're there.
this._rotation = 0;
delete this.onEnterFrame;
gotoAndPlay(31);
}
}
and it slows down then stops upside down?
Yes, you're right. You can change it to something like:
if (this.curRate <= kMinimumSpeed and Math.round(this._rotation) < 1 )
In which kMinimumSpeed is the slow speed you want ....
- Jim
wow thanks a toooooooooooooooon guys!! finally got it working alright!
nota