To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here


A Flash Developer Resource Site

Go Back   Flash Kit Community Forums > Flash Help > Flash ActionScript

Reply
 
Thread Tools Search this Thread Display Modes
Old 09-27-2004, 07:44 PM   #1
notaloserflash
Junior Member
 
Join Date: Aug 2004
Posts: 26
using AS to rotate a mc?

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?
notaloserflash is offline   Reply With Quote
Old 09-27-2004, 07:51 PM   #2
cancerinform
Mod
 
cancerinform's Avatar
 
Join Date: Mar 2002
Location: press the picture...
Posts: 12,312
i=0;
_root.mc.onEnterFrame=function(){
i++;
this._rotation =i;
}
__________________

- The right of the People to create Flash movies shall not be infringed. -
| www.Flashscript.biz | Help a little girl, Ana, who has cancer. | Flashscript Biz Classes/Components | The new Event design pattern | Clothing for Haiti |
cancerinform is offline   Reply With Quote
Old 09-27-2004, 08:14 PM   #3
jbum
Senior Member
 
jbum's Avatar
 
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
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;
}

__________________
jbum is offline   Reply With Quote
Old 09-27-2004, 08:19 PM   #4
hum
Senior Member
 
hum's Avatar
 
Join Date: Sep 2003
Location: CloudCuckooland
Posts: 1,714
Hi....
This will speed it up gradually......(this._rotation + = i;)
code:
i = 0;
_root.mc.onEnterFrame = function() {
i++;
this._rotation + = i;
};

__________________
MySite
hum is offline   Reply With Quote
Old 09-27-2004, 10:30 PM   #5
neomaximus2k
Senior Member
 
Join Date: Sep 2004
Location: West Mids, UK
Posts: 101
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.
__________________
Website Design
Flash Development
neomaximus2k is offline   Reply With Quote
Old 09-27-2004, 11:38 PM   #6
notaloserflash
Junior Member
 
Join Date: Aug 2004
Posts: 26
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

Last edited by notaloserflash; 09-27-2004 at 11:42 PM.
notaloserflash is offline   Reply With Quote
Old 09-27-2004, 11:45 PM   #7
neomaximus2k
Senior Member
 
Join Date: Sep 2004
Location: West Mids, UK
Posts: 101
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?
__________________
Website Design
Flash Development
neomaximus2k is offline   Reply With Quote
Old 09-28-2004, 12:14 AM   #8
notaloserflash
Junior Member
 
Join Date: Aug 2004
Posts: 26
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
notaloserflash is offline   Reply With Quote
Old 09-28-2004, 12:17 AM   #9
notaloserflash
Junior Member
 
Join Date: Aug 2004
Posts: 26
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?
notaloserflash is offline   Reply With Quote
Old 09-28-2004, 12:48 AM   #10
neomaximus2k
Senior Member
 
Join Date: Sep 2004
Location: West Mids, UK
Posts: 101
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?
__________________
Website Design
Flash Development
neomaximus2k is offline   Reply With Quote
Old 09-28-2004, 01:01 AM   #11
notaloserflash
Junior Member
 
Join Date: Aug 2004
Posts: 26
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?
notaloserflash is offline   Reply With Quote
Old 09-28-2004, 01:50 AM   #12
jbum
Senior Member
 
jbum's Avatar
 
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
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;
}
}

__________________

Last edited by jbum; 09-28-2004 at 01:56 AM.
jbum is offline   Reply With Quote
Old 09-28-2004, 01:59 AM   #13
jbum
Senior Member
 
jbum's Avatar
 
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
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 is offline   Reply With Quote
Old 09-28-2004, 10:51 AM   #14
neomaximus2k
Senior Member
 
Join Date: Sep 2004
Location: West Mids, UK
Posts: 101
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.
__________________
Website Design
Flash Development
neomaximus2k is offline   Reply With Quote
Old 09-28-2004, 04:47 PM   #15
notaloserflash
Junior Member
 
Join Date: Aug 2004
Posts: 26
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?

Last edited by notaloserflash; 09-28-2004 at 04:53 PM.
notaloserflash is offline   Reply With Quote
Old 09-28-2004, 05:44 PM   #16
jbum
Senior Member
 
jbum's Avatar
 
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
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
__________________
jbum is offline   Reply With Quote
Old 09-28-2004, 05:58 PM   #17
notaloserflash
Junior Member
 
Join Date: Aug 2004
Posts: 26
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

Last edited by notaloserflash; 09-28-2004 at 06:00 PM.
notaloserflash is offline   Reply With Quote
Old 09-28-2004, 06:06 PM   #18
notaloserflash
Junior Member
 
Join Date: Aug 2004
Posts: 26
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?

Last edited by notaloserflash; 09-28-2004 at 06:13 PM.
notaloserflash is offline   Reply With Quote
Old 09-28-2004, 06:14 PM   #19
jbum
Senior Member
 
jbum's Avatar
 
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
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
__________________
jbum is offline   Reply With Quote
Old 09-28-2004, 06:56 PM   #20
notaloserflash
Junior Member
 
Join Date: Aug 2004
Posts: 26
wow thanks a toooooooooooooooon guys!! finally got it working alright!

nota
notaloserflash is offline   Reply With Quote
Reply

Go Back   Flash Kit Community Forums > Flash Help > Flash ActionScript

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:58 PM.


internet.commerce
Be a Commerce Partner
 »  »  »  »  »  »  »
 »  »  »  »  »  »
 

    

Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.