Link to home
Create AccountLog in
Avatar of MikeSven
MikeSvenFlag for Canada

asked on

Papervision 2.0 MovieMaterials and flickr dynamic images

Hey Guys,

I am trying to load in some dynamic images from flickr and display them on some planes.  I currently have all of the xml information being fed into my system, and can display the images with out papervision.  I seem to be having a few issues setting up my MovieMaterial so that it is working properly.  If i trace a few things out, it looks like the flickr image is fully loaded in, but for some reason I can't get the data to show in the material.  I have also tested using some color materials just to make sure my basic 3d code is working and it all is.  I was wondering if perhaps there is anyone out there who has tried this before and can lend me a hand or lead me in the right direction.  I have built an ImageObject class, which exteds DO3D and should display a plane with the image on it the code that I am currently using is as follows:

Thanks for any help that can be offered.

Michael
package ImageGallery
{
	import flash.display.Loader;
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.events.ProgressEvent;
	import flash.net.URLRequest;
	import flash.system.LoaderContext;
	
	import org.papervision3d.materials.ColorMaterial;
	import org.papervision3d.materials.MovieMaterial;
	import org.papervision3d.objects.DisplayObject3D;
	import org.papervision3d.objects.primitives.Plane;
	
	public class ImageObject extends DisplayObject3D
	{
		private  var   imageLoader:Loader;
		private  var   imageRequest:URLRequest;
		private  var   imageContainer:MovieClip;
		
		public   var   thePlane:Plane;
		public   var   thePlaneHolder:DisplayObject3D
		public   var   thePlaneMat:MovieMaterial;
		
		private  static   const   FLICKR_IMAGE_LOADED:String = "THIS IMAGE HAS LOADED";
		
		public function ImageObject(fileURL:String)
		{
			initLoad(fileURL);
		}
		
		private function initLoad(fileURL:String):void{
			
			imageRequest = new URLRequest(fileURL);
			
			imageLoader = new Loader();
			imageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, handleImageLoadProg);
			imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, handleImageLoadComplete);
			imageLoader.load(imageRequest, new LoaderContext(true));
			
		}
		
		private function handleImageLoadComplete(e:Event):void{
			
			imageContainer = new MovieClip();
			imageContainer.addChild(imageLoader.content);
			
			addEventListener(FLICKR_IMAGE_LOADED, startMaterialBuild);
			dispatchEvent(new Event(FLICKR_IMAGE_LOADED));
			
		}
		
		private function handleImageLoadProg(e:ProgressEvent):void{
			trace(e.bytesLoaded / e.bytesTotal);
		}
		
		private function startMaterialBuild(e:Event):void{
 
			thePlaneMat = new MovieMaterial(imageContainer, false, true, true);;
			startPlaneBuild(thePlaneMat);
			
		}
		
		private function startPlaneBuild(thePlaneMaterial:MovieMaterial):void{
			
			var tempMat:ColorMaterial = new ColorMaterial(0xFFFFFF);
			thePlane = new Plane(thePlaneMat, 100, 100, 10, 10);
			thePlaneHolder = addChild(thePlane);
			
		}
 
	}
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of MikeSven
MikeSven
Flag of Canada image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer