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

Sample of EnvMaterial

...
@author ...
Get Adobe Flash player
by mtok 25 Feb 2009
    Embed
package  
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import org.papervision3d.core.view.IView;
	import org.libspark.thread.Thread;
	import org.libspark.thread.EnterFrameThreadExecutor;
	/**
	 * ...
	 * @author ...
	 */
	public class Pv3d007 extends Sprite
	{
		private var _view:CustomView;
		public function Pv3d007() 
		{
			addEventListener(Event.ADDED_TO_STAGE, addedToStageHandler);
		}
		
		private function addedToStageHandler(e:Event):void 
		{
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.frameRate = 30;

			if (!Thread.isReady) {
				Thread.initialize(new EnterFrameThreadExecutor());
			}
			
			var t:Thread = new MainThread(this);
			t.start();
		}
		
	}
}

import flash.display.Bitmap;
import flash.display.Sprite;
import flash.display.BitmapData;
import flash.display.Loader;
import flash.events.Event;
import flash.net.URLRequest;
import flash.system.ApplicationDomain;
import flash.system.LoaderContext;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;

import org.papervision3d.view.BasicView;
import org.papervision3d.objects.primitives.Cube;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.materials.special.CompositeMaterial;
import org.papervision3d.materials.shadematerials.EnvMapMaterial;
import org.papervision3d.materials.WireframeMaterial;
import org.papervision3d.lights.PointLight3D;
import org.papervision3d.core.proto.MaterialObject3D;

import org.libspark.thread.Thread;
import org.libspark.thread.threads.display.LoaderThread;
internal class MainThread extends Thread {
	private var loader:Loader;
	private var lt:LoaderThread;
	private var _view:BasicView;
	private var container:Sprite;
	public function MainThread(container:Sprite) {
		
		super();
		
		this.container = container;
	}
	override protected function run():void 
	{
		loader = new Loader();
		var req:URLRequest = new URLRequest("http://www.matzmtok.com/wonderfl/black_QP.png");
		var context:LoaderContext = new LoaderContext(true, new ApplicationDomain(null), null);
		lt = new LoaderThread(req, context,  loader);
		lt.start();
		lt.join();
		trace('run');
		next(playSample);
	}
	private function playSample():void {
		var bmp:Bitmap = loader.contentLoaderInfo.content as Bitmap;
		_view = new CustomView(bmp.bitmapData);
		container.addChild(_view);
	}
}

internal class CustomView extends BasicView {
	private var tf:TextField;
	private var cube:Cube;
	private var bmpData:BitmapData;
	public function CustomView(bmpData:BitmapData) {
		super(0, 0, true, true);
		
		this.bmpData = bmpData;
		
		buildScene();
		startRendering();
		addEventListener(Event.ENTER_FRAME, enterFrameHandler);
	}
	
	private function enterFrameHandler(e:Event):void 
	{
		cube.rotationX += 1;
		cube.rotationY += 1;
		cube.rotationZ += 1;
	}
	
	protected function buildScene():void {
		var cmat:CompositeMaterial = new CompositeMaterial();
		var ml:MaterialsList = new MaterialsList();
		
		var pointLight:PointLight3D;
		pointLight = new PointLight3D(true);
		pointLight.z = -800;
		pointLight.y = 300;
		pointLight.x = 300;
		
		var evmat:EnvMapMaterial;
		evmat = new EnvMapMaterial(pointLight, bmpData, bmpData, 0xffffff);
		cmat.addMaterial(evmat);
		//cmat.addMaterial(new WireframeMaterial(0xff0000, 1, 1));
		ml.addMaterial(cmat, "all");
		
		cube = new Cube(ml, 100, 100, 100, 8,8,8);
		scene.addChild(cube, "cube");
		
		camera.x = 0;
		camera.y = 0;
		camera.z = -400;
	}
}