Link to home
Start Free TrialLog in
Avatar of cubical38
cubical38

asked on

AS3: Zooming in on an individual object in pv3d carousel

Okay now that I am able to target individual objects within this pv3d carousel, how do I go about creating a zoom effect to each individual objects without having to zoom in on the entire DisplayObject3D?

For example as the objects rotate, I want to be able to roll over/ and or click on the individual images and bring them closer while the other objects remain at their original distance.  I have been able to add an alpha tween to individual objects but not a scale, unless I am targeting the wrong object.

As always all help is greatly appreciated, so Thanks!
//the class at hand:
package {
	
	import flash.events.Event;
	import flash.filters.BlurFilter;
	import flash.geom.ColorTransform;
	import flash.geom.Point;
	import gs.*;
	
	import fl.transitions.easing.*;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.utils.*;
	import flash.events.MouseEvent;
	import flash.display.MovieClip;
	import flash.display.BitmapData;
	import flash.display.Bitmap;
	import flash.geom.Point;
	import org.papervision3d.materials.ColorMaterial;
	import org.papervision3d.objects.DisplayObject3D;
	import org.papervision3d.events.InteractiveScene3DEvent;
	import org.papervision3d.objects.primitives.Plane;
	import org.papervision3d.view.BasicView;
	import org.papervision3d.view.Viewport3D;
	import org.papervision3d.materials.MovieMaterial;
	import org.papervision3d.core.effects.view.ReflectionView;
	//import caurina.transitions.Tweener;
	//import caurina.transitions.properties.FilterShortcuts;

	[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:Viewport3D=new Viewport3D(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  ;
		private var view :ReflectionView;
		
		public function InternalCarousel() {
			
			
			super(940, 300, true, true);
			
			addChild(bitmapViewport);
			bitmapViewport.interactive=true;
			
			camera.z=1;
			
			for (var i:int=0; i<NUMBER_OF_PLANES; i++) {
				var picLoader:MovieClip=new MovieClip  ;
				
				/*var xmlData:XML = new XML();
				var xmlList:XMLList = new XMLList();
				var currentPic:int=0;
				var xmlLoader:URLLoader = new URLLoader();

				xmlLoader.addEventListener(Event.COMPLETE, onComplete);
				xmlLoader.load(new URLRequest("#"));

				function onComplete(e:Event):void {
					trace("complete");
					xmlData=new XML(e.target.data);
					xmlData=new XML(xmlLoader.data);
					xmlList=xmlData.solutions;

					updatePic(currentPic);
				}

				function updatePic(index:int):void {
					trace("updatePic");
					var Length=xmlList.length();
					index=index%Length;
					zoomBg.copy_mc.copyTxt.text=xmlList[index].copy;

					picLoader.load(new URLRequest(xmlList[index].pic));
					zoomBg.copy_mc.readMore_mc.addEventListener(MouseEvent.CLICK, GetUrTix);
					function GetUrTix(e:MouseEvent):void {
						navigateToURL(new URLRequest(xmlList[index].url), "_self");
					}
				}*/
				
				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;

				var plane:Plane=new Plane(material,360,280);
				plane.addEventListener(InteractiveScene3DEvent.OBJECT_OVER,tellMeSomething);
				plane.addEventListener(InteractiveScene3DEvent.OBJECT_OUT,tellMeNothing);
				plane.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK,showMeSomething);
				plane.rotationY=360/NUMBER_OF_PLANES*i;
				plane.moveForward(900);
				plane.extra = {movie:picLoader};
				carousel.addChild(plane);
				
				view = new ReflectionView(viewportWidth, viewportHeight);
				addChild(view);
				view.singleRender();
			}

			scene.addChild(carousel);

			startRendering();
		}

		function tellMeSomething(e:InteractiveScene3DEvent):void{
			var mat:MovieMaterial = e.currentTarget.material as MovieMaterial;
			var mc:MovieClip = mat.movie as MovieClip;
			TweenLite.to(mc, .2, {alpha: .3, ease:Strong.easeIn});
			trace("over = " + mc);
		}
		function tellMeNothing(e:InteractiveScene3DEvent):void{
			var mat:MovieMaterial = e.currentTarget.material as MovieMaterial;
			var mc:MovieClip = mat.movie as MovieClip;
			TweenLite.to(mc, .2, {alpha: 1, ease:Strong.easeIn});
			trace("out = " + mc);
		}
		function showMeSomething(e:InteractiveScene3DEvent):void{
			var mat:MovieMaterial = e.currentTarget.material as MovieMaterial;
			var mc:MovieClip = mat.movie as MovieClip;
			trace("into = " + mc);
		}
		
		override protected function onRenderTick(event:Event=null):void{
			
			carousel.rotationY-=viewport.containerSprite.mouseX/200;

			renderer.renderScene(scene,camera,bitmapViewport);
			
		}
	}
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of TanLiHao
TanLiHao
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cubical38
cubical38

ASKER

Thanks so much for the reply!

I have moved my tellMeSomething, tellMeNothing and showMeSomething functions within the main class function.  I have added rotationY to mc, plane, mat and material with no luck.  the only way I have been able to get any manipulation is to adjust the z property of the camera, but this moves the entire carousel and not just the individual objects.  This is also very choppy...  If there is a better way to target the individual planes or mcs on the MovieMaterial (as I will use them to place images in) I am all ears.  I have provided my .fla and my class.  This is all based on the papervision3D classes so I have not uploaded the org folder.

Thanks again and I hope you can help!
Archive.zip.txt
Rewrote the code, asked new question that is related but wouldnt fit here.
I spotted your other question, I was preparing to help you on that but because that requires some work I haven't replied to it yet. If https://www.experts-exchange.com/questions/25006682/AS3-XML-in-pv3D-adding-images-to-the-planes.html?cid=1749 is the same question, let's continue from there and abandon this question.
I have just spent some time helping you on that question and you deleted it, you should have told me here if you wanted to delete that.
I will open another question, so you can get your points for the work you did.  Sorry!  I am opening it now...
The thing is it's perfectly alright to delete your own question(of course it's your own question). However, since you sort of linked me to that and then you deleted it without telling me you do not need help anymore just seems to be (blabla). I couldn't find the word to describe it but telling me to help and deleting the question is like asking me to help you and you running away from me.