/ Published in: ActionScript 3
More information, Demo & FLA file download at http://www.adamcoulombe.info/lab/as3/spiral-gallery.html
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
import com.greensock.*; import com.greensock.easing.*; var galItems = new Array(); for(var i=0; i<40; i++){ var rad = (i * 12) + 60 ; galItems[i]=new Box(); galItems[i].x = Math.sin(rad) * rad; galItems[i].y = Math.cos(rad) * rad; galItems[i].z = (i - 20) * 40; galItems[i].rotationY = 90; trace(rad); ///////// This was tricky! Thanks to http://www.foundation-flash.com/tutorials/as3rotation/ galItems[i].selfRotX = (rad /(Math.PI /180)) + 90 ; ///////// galItems[i].rotationX = galItems[i].selfRotX ; gallery.helix.addChild(galItems[i]); gallery.z = 800; } addEventListener(Event.ENTER_FRAME,loop); function loop(e){ var distx:Number = mouseX / 650; var disty:Number = mouseY / 450; TweenLite.to(gallery, 2, { rotationY: 90 + ((-70 + (140*distx))*0.6), rotationX:(70 - (140*disty))*0.6, ease:Expo.easeOut }); TweenLite.to(gallery.helix, 2, {rotation: (mouseX - (stage.stageWidth/2)) * 1.6}); /* for (var i =0; i< galItems.length; i++){ TweenLite.to(galItems[i], 2, {rotationX: (galItems[i].selfRotX + mouseX - (stage.stageWidth/2 )) -90 }); } */ }
URL: http://www.adamcoulombe.info/lab/as3/spiral-gallery.html