AS3 3D Spinning Spiral in Flash Gallery Effect


/ Published in: ActionScript 3
Save to your folder(s)

More information, Demo & FLA file download at http://www.adamcoulombe.info/lab/as3/spiral-gallery.html


Copy this code and paste it in your HTML
  1. import com.greensock.*;
  2. import com.greensock.easing.*;
  3.  
  4.  
  5. var galItems = new Array();
  6. for(var i=0; i<40; i++){
  7. var rad = (i * 12) + 60 ;
  8. galItems[i]=new Box();
  9. galItems[i].x = Math.sin(rad) * rad;
  10. galItems[i].y = Math.cos(rad) * rad;
  11. galItems[i].z = (i - 20) * 40;
  12. galItems[i].rotationY = 90;
  13. trace(rad);
  14.  
  15. ///////// This was tricky! Thanks to http://www.foundation-flash.com/tutorials/as3rotation/
  16. galItems[i].selfRotX = (rad /(Math.PI /180)) + 90 ;
  17. /////////
  18.  
  19. galItems[i].rotationX = galItems[i].selfRotX ;
  20. gallery.helix.addChild(galItems[i]);
  21. gallery.z = 800;
  22. }
  23.  
  24. addEventListener(Event.ENTER_FRAME,loop);
  25.  
  26. function loop(e){
  27.  
  28. var distx:Number = mouseX / 650;
  29. var disty:Number = mouseY / 450;
  30. TweenLite.to(gallery, 2, {
  31. rotationY: 90 + ((-70 + (140*distx))*0.6),
  32. rotationX:(70 - (140*disty))*0.6,
  33. ease:Expo.easeOut
  34. });
  35. TweenLite.to(gallery.helix, 2, {rotation: (mouseX - (stage.stageWidth/2)) * 1.6});
  36. /*
  37. for (var i =0; i< galItems.length; i++){
  38. TweenLite.to(galItems[i], 2, {rotationX: (galItems[i].selfRotX + mouseX - (stage.stageWidth/2 )) -90 });
  39.  
  40. } */
  41.  
  42. }

URL: http://www.adamcoulombe.info/lab/as3/spiral-gallery.html

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.