In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

Cube Reflection 2

...
@author Gustavo Pitombo
http://www.gustavopitombo.com.br
Get Adobe Flash player
by pitombo 06 May 2010
/**
 * Copyright pitombo ( http://wonderfl.net/user/pitombo )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/7m9e
 */

// forked from pitombo's Cube Reflection
package 
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.Matrix;
	import org.papervision3d.core.effects.view.ReflectionView;
	import org.papervision3d.lights.PointLight3D;
	import org.papervision3d.materials.shadematerials.FlatShadeMaterial;
	import org.papervision3d.materials.utils.MaterialsList;
	import org.papervision3d.objects.primitives.Cube;
	
	/**
	 * ...
	 * @author Gustavo Pitombo
	 * http://www.gustavopitombo.com.br
	 */
	public class Cubo3d extends ReflectionView
	{
		private var Cubo:Cube;
		private var light:PointLight3D;
		private var mat:FlatShadeMaterial;
		private var matList:MaterialsList;
		
		public function Cubo3d()
		{
			viewportReflection.alpha = .5;
			
			light = new PointLight3D();
			mat = new FlatShadeMaterial(light, 0xff3232, 0x00);
			matList = new MaterialsList();
			matList.addMaterial(mat, "all");
				
			Cubo = new Cube(matList, 300, 300, 300, 2, 2, 2, 0, 0);
			Cubo.y = 250;
			scene.addChild(Cubo);
				
			var sombra:Sprite = new Sprite();
			var matr:Matrix = new Matrix();
			matr.createGradientBox(450, 150, Math.PI/2);
			sombra.graphics.beginGradientFill("linear", [0xffffff, 0xffffff], [0, 1], [0, 255], matr, "pad", "rgb", -10);
			sombra.graphics.drawRect(0, 0, 480, 200);
			sombra.graphics.endFill();
			sombra.y = 250;
			addChild(sombra);
			
			addEventListener(Event.ENTER_FRAME, _render, false, 0, true);
		}
		
		private function _render(e:Event):void 
		{
			singleRender();
			
			Cubo.rotationX += 1;
			Cubo.rotationY += 2;
		}
	}	
}