rotating an object, please help

  • FF
  • Newbie
  • Newbie
  • FF
  • Posts: 6

Post 3+ Months Ago

:oops:
hello guys,
i would really appreciate if smbd. could help me doing following:
i have an object in flashMX and i want this object to rotate automatically in loop modus, each time i enter my site.
what should i put into actionscript?
please tell in details
thank you thank you
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • FF
  • Newbie
  • Newbie
  • FF
  • Posts: 6

Post 3+ Months Ago

:oops: hello again,
i found an example for what i mean by rotating an object.
when you put the mouse over the scroll star, it starts to rotate and i want that my object rotates all the time when i enter the first scene of my site
here example: http://www.metclub.com/
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

Place this in the main timeline,
Code: [ Select ]
function spin(inc){
    rota._rotation+=inc;
}
setInterval(spin,10,2);
  1. function spin(inc){
  2.     rota._rotation+=inc;
  3. }
  4. setInterval(spin,10,2);


Where rota is the name of the movieclip to be rotated.
In the setInterval replace 10 with the number of milliseconds between each step of the rotation, and replace 2 with the number of degrees to rotate the movieclip for each step of the rotation.

This is set to rotate to the right, to rotate to the left replace the += in the spin function with -=

:D
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

You can use the onEnterFrame dynamic event handler instead of setInterval as well...

Code: [ Select ]
clipInstanceName.onEnterFrame = function(){
this._rotation += number
}
  1. clipInstanceName.onEnterFrame = function(){
  2. this._rotation += number
  3. }
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

I know you have more experience with flash than I do lostinbeta so I ask,

What are the pros and cons of each of our methods for doing this ? :D
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

The setInterval method calls the rotation based on a set amount of milliseconds.

The onEnterFrame method runs it constantly based on the fps rate for the document.

So yours will run the same speed no matter what the fps, mine will not. That could be looked upon as a con.

However, you are also repeatedly calling a function every 10 milliseconds. Which i'm not sure if it will happen in this case, but it could end up being more CPU intensive.


Also with your current code, I would recommend giving your setInterval and intervalID so you can clear it later if needed. For example
Code: [ Select ]
function spin(inc){
  rota._rotation+=inc;
}
rotateMC = setInterval(spin,10,2);

//clear it via...
clearInterval(rotateMC);
  1. function spin(inc){
  2.   rota._rotation+=inc;
  3. }
  4. rotateMC = setInterval(spin,10,2);
  5. //clear it via...
  6. clearInterval(rotateMC);


To stop running mine you would use
Code: [ Select ]
clipInstanceName.onEnterFrame = function(){
this._rotation += number
}
//clear it via...
delete clipInstanceName.onEnterFrame;
  1. clipInstanceName.onEnterFrame = function(){
  2. this._rotation += number
  3. }
  4. //clear it via...
  5. delete clipInstanceName.onEnterFrame;
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

So unless you have an oddball framerate, and tiny functions being called onEnterFrame is generally better to use than setInterval ?
  • FF
  • Newbie
  • Newbie
  • FF
  • Posts: 6

Post 3+ Months Ago

:( hhhmm well thank for the answer, BUT i must have done smth. wrong coz it duznt work.

let's assume: in the frame 1 i have a triangle, that's all i have at the moment, then i opened the actions section and pasted your code

PHP Code: [ Select ]
function spin(inc){
 
   rota._rotation+=inc;
 
}
 
setInterval(spin,10,2);
  1. function spin(inc){
  2.  
  3.    rota._rotation+=inc;
  4.  
  5. }
  6.  
  7. setInterval(spin,10,2);


i know it's sounds silly but i'm beginner
could xou explain me in very detalis, step by step
pleeeeaaaassee :(
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

@joebert: onEnterFrame is generally used when you want the animation to run at the same FPS rate as your movie. It keeps things semi-consistant. It is most common for onEnterFrame to be used in this situation than it is for setInterval to be used. It's cleaner, and less coding.

@FF: Did you read instructions on how to use it in his post? rota is the movieclips instance name, spin is the function being called, 10 is the amount of milliseconds between each time the function is called and 2 is the amount of rotation your clip should rotate.
  • suzie
  • Guru
  • Guru
  • User avatar
  • Posts: 1134
  • Loc: England

Post 3+ Months Ago

Hey, thanks i'm gonna practice with that code..err...in Swish though !
:)
I love trying new things, and i am trying to make a banner so this may be just the ticket for one idea.
suzie.

Post Information

  • Total Posts in this topic: 10 posts
  • Users browsing this forum: No registered users and 9 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.