Return to Snippet

Revision: 34416
at October 22, 2010 04:44 by adamcoulombe


Initial Code
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 });
		
	} */
	
}

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

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

Initial Title
AS3 3D Spinning Spiral in Flash Gallery Effect

Initial Tags
flash

Initial Language
ActionScript 3