We Recommend

SQL Cookbook SQL Cookbook
Written in O'Reilly's popular Problem/Solution/Discussion style, the SQL Cookbook is sure to please. Anthony's credo is: "When it comes down to it, we all go to work, we all have bills to pay, and we all want to go home at a reasonable time and enjoy what's still available of our days." The SQL Cookbook moves quickly from problem to solution, saving you time each step of the way.


Posted By

blackabee on 06/20/08


Tagged

speed rotation as2 Spin movement acceleration


Versions (?)


Who likes this?

1 person has marked this snippet as a favorite

jeeStyle


Spin - Rotation Movement with Acceleration


Published in: ActionScript 


Use this bit of code to rotate a MC at a set speed or accelerate at a desired increment.

  1. onClipEvent(load) {
  2. // Initialize spin speed to 0.
  3. speed = .01;
  4. // Acceleration speed.
  5. accel = 0;
  6. // Every frame execute the following code.
  7. this.onEnterFrame = function(){
  8. // Increment speed by the acceleration.
  9. speed = Math.round((speed + accel)*100)/100;
  10. // Rotate the shape by the current spin speed.
  11. _rotation += speed;
  12. }
  13. }

Report this snippet 

You need to login to post a comment.