Entry: papervision3D flickr
Description
Papervision 3D is a simple but powerful library for making 3D effects in flash. Download it at Google Code and play around, as you can see in the code below there are just a few lines necessary to start in the third dimension.
I used the flickr API to let it rain random images retrieved from flickr matching the keyword.
import org.papervision3d.scenes.*;
import org.papervision3d.cameras.*;
import org.papervision3d.objects.*;
import org.papervision3d.materials.*;
import com.UrbanSky.ImageLoader;
import com.UrbanSky.HTTPLoader;
import com.UrbanSky.SmoothFade;
import com.UrbanSky.SmoothMove;

var keyword = root.loaderInfo.parameters.keyword;
var container:Sprite = new Sprite();
container.x = stage.stageWidth / 2;
container.y = stage.stageHeight / 2;
addChild(container);

var scene:Scene3D = new Scene3D(container);
var camera:Camera3D = new Camera3D();
camera.zoom = 3;

this.addEventListener(Event.ENTER_FRAME, render);
function render(e:Event):void{
	scene.renderCamera(camera);
}
this.addEventListener(Event.ENTER_FRAME,fallDown);
function fallDown(e:Event){
  for (var i:Number = 0; i < scene.objects.length; ++i){
    scene.objects[i].y -= speeds[i];
    scene.objects[i].rotationY += rotations[i];
    if (scene.objects[i].y < -1000) setPlaneProperties(scene.objects[i],i);
  }
}

var rotations = new Array();
var speeds = new Array();
function buildTree(ImageHolder:MovieClip){
  for (var i:Number = 0; i < ImageHolder.numChildren; ++i){
    var bmd:BitmapData = Loader(ImageHolder.getChildAt(i)).content.bitmapData;
    var bm:BitmapMaterial = new BitmapMaterial(bmd);
    bm.oneSide = false;
    bm.smooth = true;
    var p:Plane = new Plane(bm,350,350,2,2);
    setPlaneProperties(p,null);
    scene.addChild(p);
    rotations.push(Math.random()*20+3);
    speeds.push(Math.random()*10+1);
  }
  var sf:SmoothFade = new SmoothFade();
  var sm:SmoothMove = new SmoothMove();
  sf.fade(Loading,0);
  sm.move(Loading,Loading.x,450,100);
}
function setPlaneProperties(p,i){
	p.x = Math.random() * 1000 - 500;
	p.y = Math.random() * 3000 + 1800;
	p.z = Math.random() * 1000 - 500;
	p.rotationY = Math.random() * 360;
	if ( i !== null){
		rotations[i] = Math.random()*20+3;
		speeds[i] = Math.random()*20+1;
	}
}

function bt(rsp){
	var urls:Array = rsp.split("#");
	IL.loadImages(urls);
}
var httploader:HTTPLoader = new HTTPLoader('http://yourdomain.com/script',bt);
httploader.load(["keywords",keyword],["maxImages",30]);
var IL:ImageLoader = new ImageLoader(this);

  
Comments

NameE-Mail
send


Creative Commons License