as3: add movieclip to pv3d plane to use as an image loader

I am trying to add movieclips to the individual planes on the carousel, so that I can add images to the planes.  What is my next step here?

Creating a carousel with this pv3d class and want to use the planes as image loaders or add a mc to the planes so that the rotation stays, but i can then add images to the planes...
package {
	import flash.events.Event;
	import flash.filters.BlurFilter;
	import flash.geom.ColorTransform;
	import flash.geom.Point;

	import fl.transitions.easing.*;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.utils.*;
	import flash.events.MouseEvent;
	import flash.display.Sprite;
	import flash.display.BitmapData;
	import flash.geom.Point;
	import org.papervision3d.materials.ColorMaterial;
	import org.papervision3d.objects.DisplayObject3D;
	import org.papervision3d.objects.primitives.Plane;
	import org.papervision3d.view.BasicView;
	import org.papervision3d.view.BitmapViewport3D;

	[SWF(width="940",height="300",backgroundColor="#ffffff",frameRate="60")]
	public class InternalCarousel extends BasicView {
		private static const NUMBER_OF_PLANES:int=11;

		private var carousel:DisplayObject3D=new DisplayObject3D  ;
		private var bitmapViewport:BitmapViewport3D=new BitmapViewport3D(940,300);
		private const blur:BlurFilter=new BlurFilter(0,0,0);
		private const alphaTrans:ColorTransform=new ColorTransform(1,1,1,1,1,1,1,-35);
		private var point:Point=new Point  ;
		trace("this is working");


		public function InternalCarousel() {
			bitmapViewport.fillBeforeRender=false;
			addChild(bitmapViewport);
			camera.z=1;
			for (var i:int=0; i<NUMBER_OF_PLANES; i++) {
				var randomColor:Number=Math.random()*0xffffff;
				var colorMaterial:ColorMaterial=new ColorMaterial(randomColor);
				colorMaterial.doubleSided=true;

				var plane:Plane=new Plane(colorMaterial,360,280);
				plane.rotationY=360/NUMBER_OF_PLANES*i;
				plane.moveForward(900);
				carousel.addChild(plane);
				trace("plane = "+plane);

				var picLoader:Sprite=new Sprite  ;
				addChild(picLoader);
				picLoader.graphics.beginFill(0x00FF00,1);
				picLoader.graphics.drawRect(0,0,180,150);
				picLoader.graphics.endFill();
				picLoader.rotationY=360/NUMBER_OF_PLANES*i;
				picLoader.x=plane.x;
				picLoader.y=plane.y;
			}

			scene.addChild(carousel);

			startRendering();
		}

		override protected function onRenderTick(event:Event=null):void {
			carousel.rotationY-=viewport.containerSprite.mouseX/200;

			renderer.renderScene(scene,camera,bitmapViewport);
			bitmapViewport.bitmapData.applyFilter(bitmapViewport.bitmapData,bitmapViewport.bitmapData.rect,point,blur);
			bitmapViewport.bitmapData.colorTransform(bitmapViewport.bitmapData.rect,alphaTrans);
		}
	}
}

Open in new window

cubical38Asked:
Who is Participating?
 
72lionsConnect With a Mentor Commented:
I changed you file and it works fine. Now, you will see that on the tellmesomething function I added a couple of lines which get you access to the material (movieclip) of the plane that you mouse over.

Something else. You can't have an interactive scene with an BitmapViewport3D so I changed it to a simple Viewport3D. This had as a result your filters not to work. But search google for "pv3d EffectLayer" and you will find examples on how to use filters on your scene.
InternalCarousel.as.txt
0
 
72lionsCommented:
Instead of a ColorMaterial use a MovieMaterial. In the following example you will change the shape with tha name fo the MovieClip that you want to use:

You can also check the following:

http://pv3d.org/tag/moviematerial/
http://flashenabledblog.com/2008/05/14/video-tutorial-pv3d-interactive-moviematerial-and-cube-navigation/


var material:MovieMaterial = new MovieMaterial(shape);
//animated needs to be true to tween the color
material.animated = true;
material.doubleSided = true;
material.interactive = true;
 
var plane:Plane = new Plane(material, 100, 100);

Open in new window

0
 
cubical38Author Commented:
Excellent thanks for the reply.  One question...  How do i then target each individual plane?  As to say if I want a MOUSE_OVER and or CLICK for each material.

Thanks!


public function InternalCarousel() {
			bitmapViewport.fillBeforeRender=false;
			addChild(bitmapViewport);
			camera.z=1;
			for (var i:int=0; i<NUMBER_OF_PLANES; i++) {
				/*var randomColor:Number=Math.random()*0xffffff;
				var colorMaterial:ColorMaterial=new ColorMaterial(randomColor);
				colorMaterial.doubleSided=true;*/
				var picLoader:Sprite=new Sprite;
				
				picLoader.graphics.beginFill(0x00FF00,1);
				picLoader.graphics.drawRect(0,0,180,150);
				picLoader.graphics.endFill();
				picLoader.rotationY=360/NUMBER_OF_PLANES*i;
				//addChild(picLoader);
				
				var material:MovieMaterial=new MovieMaterial(picLoader);

				material.animated=true;
				material.doubleSided=true;
				material.interactive=true;
				material.addEventListener(MouseEvent.MOUSE_OVER, tellMeSomething);
				function tellMeSomething(event:MouseEvent):void {
					trace("something good");
				}

				var plane:Plane=new Plane(material,360,280);
				
				plane.rotationY=360/NUMBER_OF_PLANES*i;
				plane.moveForward(900);
				carousel.addChild(plane);
				trace("plane = "+plane);
			}

			scene.addChild(carousel);

			startRendering();
		}

Open in new window

0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
cubical38Author Commented:
Ive tried the following but the stage is blank upon testing:
var picLoader:Sprite=new Sprite  ;

				picLoader.graphics.beginFill(0x00FF00,1);
				picLoader.graphics.drawRect(0,0,180,150);
				picLoader.graphics.endFill();
				picLoader.rotationY=360/NUMBER_OF_PLANES*i;

				var material:MovieMaterial=new MovieMaterial(picLoader);

				material.animated=true;
				material.doubleSided=true;
				material.interactive=true;
				plane.addEventListener(InteractiveScene3DEvent.OBJECT_OVER,tellMeSomething);

				function tellMeSomething(event:InteractiveScene3DEvent):void {
					trace("something good");
				}

				var plane:Plane=new Plane(material,360,280);

				plane.rotationY=360/NUMBER_OF_PLANES*i;
				plane.moveForward(900);
				carousel.addChild(plane);

Open in new window

0
 
72lionsCommented:
You will add the listeners to each movieclip and then you have to add the following line:

bitmapViewport.interactive=true
0
 
cubical38Author Commented:
I am unable to add the event LIstener.  Nothing happens if I add ot to picLoader, material or plane.  The only way I am even able to see interactivity is if I add the listener to bitmapViewport.  Do I need to drill down into the bitmapViewport?  ie: bitmapViewport.picLoader


public function InternalCarousel() {
			bitmapViewport.fillBeforeRender=false;
			addChild(bitmapViewport);
			bitmapViewport.interactive=true;
			camera.z=1;
			for (var i:int=0; i<NUMBER_OF_PLANES; i++) {
				var picLoader:MovieClip=new MovieClip  ;

				picLoader.graphics.beginFill(0x00FF00,1);
				picLoader.graphics.drawRect(0,0,180,150);
				picLoader.graphics.endFill();
				picLoader.rotationY=360/NUMBER_OF_PLANES*i;

				var material:MovieMaterial=new MovieMaterial(picLoader);

				material.animated=true;
				material.doubleSided=true;
				material.interactive=true;
				//picLoader.addEventListener(InteractiveScene3DEvent.OBJECT_OVER,tellMeSomething);
				picLoader.addEventListener(MouseEvent.MOUSE_OVER,tellMeSomething);

				function tellMeSomething(event:MouseEvent):void {
					trace("something good");
				}


				var plane:Plane=new Plane(material,360,280);

				plane.rotationY=360/NUMBER_OF_PLANES*i;
				plane.moveForward(900);
				carousel.addChild(plane);
			}

Open in new window

0
 
72lionsCommented:
The InteractiveScene3DEvent is added to a 3D object, e.x. a Plane. So try doing the following:
plane.addEventListener(InteractiveScene3DEvent.OBJECT_OVER,tellMeSomething);

Open in new window

0
 
72lionsCommented:
If you still have problem please send me the class file and the fla file so that I can check it.
0
 
cubical38Author Commented:
Yea I am now getting:
1150: The protected attribute can only be used on class property definitions.
Archive.zip.txt
0
 
cubical38Author Commented:
PERFECT!  Thanks for all the help.  I will search for the best way to add a filter.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.