flash on 2010-8-4
/**
* Copyright yd_niku ( http://wonderfl.net/user/yd_niku )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/CTtn
*/
package {
import flash.system.LoaderContext;
import flash.display.*;
import flash.events.*;
import flash.net.*;
import org.papervision3d.objects.primitives.Sphere;
import org.papervision3d.view.BasicView;
import org.papervision3d.materials.*;
[SWF(backgroundColor='0x000000')]
public class FlashTest extends BasicView {
public function FlashTest() {
// write as3 code here..
super(465,465);
camera.far = 30;
camera.near = 20;
loadMaterial();
}
private var _earth:Sphere;
private function loadMaterial():void{
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onLoadMaterial);
loader.load( new URLRequest("http://lab.alumican.net/wonderfl/fp10sphere/texture.png"), new LoaderContext(true) );
}
private function onLoadMaterial(e:Event):void{
LoaderInfo(e.currentTarget).removeEventListener(Event.COMPLETE,onLoadMaterial);
var content:BitmapData = Bitmap( LoaderInfo(e.currentTarget).content ).bitmapData;
var material:BitmapMaterial = new BitmapMaterial(content);
scene.addChild(_earth = new Sphere(material,200, 8, 8));
startRendering();
addEventListener(Event.ENTER_FRAME,loop);
}
private function loop(e:Event):void{
_earth.rotationY += 3
}
}
}