Archive for December 11th, 2008

Hosting problems

Thursday, December 11th, 2008 | announcements | Comments

It looks like I’m having some troubles with my hosting for images, source, and example .swfs.

Please be patient while I try to resolve this.

Thanks,

John

*update – Looks like everything is good again. Back to cranking out examples.

Swapping a Plane with a MovieClip

Thursday, December 11th, 2008 | examples, tutorials | Comments

The idea here is to setup your material as normal and bring the plane front and center. When the plane reaches front and center, you put your regular 2d object on top and start it playing (or start interaction, etc.). Then when it’s time to go back into plane form, use plane.material.bitmap.draw(embeddedVideo) to update your material to the latest snapshot of where the video left off.

Don’t get too hung up on the tweening code. It’s not important to the concept.

The .swf is about 2 megs, so be patient while it loads.

source

package
{
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	import flash.text.TextFormat;
 
	import gs.TweenMax;
	import gs.easing.Quad;
	import gs.events.TweenEvent;
 
	import org.papervision3d.events.InteractiveScene3DEvent;
	import org.papervision3d.materials.MovieMaterial;
	import org.papervision3d.objects.primitives.Plane;
	import org.papervision3d.view.BasicView;
 
	[SWF(width="640", height="480", backgroundColor="#ffffff", frameRate="60")]
	public class SwappingPlanesWithMovieClips extends BasicView
	{
		private var embeddedVideo:MovieClip = new theoffice();
		private var plane:Plane;
 
		private var moveForwardTween:TweenMax;
		private var moveBackTween:TweenMax;
 
		private var moveBackObject:Object;
		private var moveForwardObject:Object;
 
		private var isMovingForward:Boolean = true;
 
		public function SwappingPlanesWithMovieClips()
		{
			camera.focus = 10;
			camera.zoom = 100;
 
			viewport.interactive = true;
 
			embeddedVideo.visible = false;
			embeddedVideo.stop();
			embeddedVideo.addEventListener(MouseEvent.CLICK, embeddedVideo_clickHandler);
			viewport.addChild(embeddedVideo);
 
			var initialMovieMaterial:MovieMaterial = new MovieMaterial(embeddedVideo);
			initialMovieMaterial.interactive = true;
 
			plane = new Plane(initialMovieMaterial);	
			plane.x = 500;
			plane.y = 500;
			plane.z = 3000;
			plane.rotationY = 40;
			plane.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK, plane_objectClickHandler);
 
			scene.addChild(plane);
 
			moveForwardObject = {x:0, y:0, z:0, rotationY:0, ease:Quad.easeInOut};
			var time:Number = 2;
			moveForwardTween = new TweenMax(plane, time, moveForwardObject);
			moveForwardTween.addEventListener(TweenEvent.COMPLETE, moveForwardTween_completeHandler);
 
 
			startRendering();
		}
 
		private function toggleDirection():void
		{
			isMovingForward = !isMovingForward;
		}
 
		private function moveForwardTween_completeHandler(event:TweenEvent):void
		{
			if(isMovingForward)
			{
				embeddedVideo.visible = true;
				embeddedVideo.play();
				toggleDirection();
			}
		}
 
		private function plane_objectClickHandler(event:InteractiveScene3DEvent):void
		{
			toggleDirection();
			moveForwardTween.reverse();
		}
 
		private function embeddedVideo_clickHandler(event:MouseEvent):void
		{
			plane.material.bitmap.draw(embeddedVideo);
 
			embeddedVideo.visible = false;
			embeddedVideo.stop();
 
			moveForwardTween.reverse();
		}
	}
}

Also, you can watch that clip of “The Office” here: http://www.hulu.com/watch/47992/the-office-the-surplus—magic-tricks

Search

Recommended Books

Speaking at FITC Toronto

 

December 2008
M T W T F S S
« Nov   Jan »
1234567
891011121314
15161718192021
22232425262728
293031  

Preferred Video Tutorial Resolution

  • 1024x768 (53%, 85 Votes)
  • 1280x1024 (15%, 24 Votes)
  • 1920x1080 (15%, 24 Votes)
  • 800x600 (13%, 20 Votes)
  • 480x320 (4%, 6 Votes)
  • 640x480 (0%, 2 Votes)

Total Voters: 160

Loading ... Loading ...