Category: Papervision

9

11 Must Have Flash Resources and 11 Must Have Utilities For 2009


Here's my list of 11 shweet resources and utilities for Flash Developers for the upcoming year. Some of these will look familiar to you from 2008 and possibly even earlier, but their significance and continued development will see them into 2009 and beyond. With the release of CS4, expect to see upgrades and revitalization of a number of projects as new features of the latest version of Flash are incorporated.

Resources:

1. Papervision 3D + VectorVision
Now that Papervision has taken hold of the Flash community, what next? I decided to add it to this list, as I believe 2009 to be the year of PV3D optimization and streamlining. With the new features of CS4, along with GPU processing being utilized for rendering outside of full-screen mode, the upcoming year will see those chugging experiments running smoother with significant FPS gains. In Flash 10, the Graphics.drawTriangles method gives us the ability to draw triangles using UV and UVW coordinates natively which will strip a lot of code out of the engine. This will help enable the team to squeeze every ounce of efficiency out of Papervision which is the key to Papervision evolving and making it a lasting tool. All that being said, expect to see more pushing of the envelope and more amazing experiments. Along with Papervision, I'm excited to see the evolution of Vectorvision, the vector based add-on to the Papervision library. Creating font class files that can then be used to create 3D display objects, gives us another color in the artists palette. I'm hoping to see more drawing capabilities added very soon.

UPDATE: Vectorvision's Mark Barcinski is now a member of the Papervision team. Vectorvision code will get folded into the library making things a bit more convenient with updates. Also Tim Knip has released a triangulation lib which makes it easy to convert a Vectorvision object to DisplayObject3D. This provides shading, texturing, and quadrant engine functionality. This will also lead the way for extrusion!

2. Ribbit
One of the coolest things to come out of 2008 is Ribbit. So cool, that I have also added it to my 2009 list. The creative possibilities with Ribbit are endless. Imagine plugging your Flash application into a phone jack. Keep an eye out for Ribbit's Killer App Contest which will generate a great deal of ideas. I see a significant increase in viral development using Ribbit in 2009, as well as incorporated into social networking, digital artistic pieces, and more.

3. Go + HydroTween
This is 1 of 2 of my shameless plugs, but try and think of this in terms of the big picture. Forgetting Hydrotween, Go is more then a foundation for a Tweening engine. It's the pulse for anything that has a beginning, an end, or any level of frequency. Go made a modest dent in the development community in 2008, but I feel the best is yet to come. I'm hopeful that physics, more creative Tweening utilities, and even more 3D control and deforming modifiers will find their way to goplayground in 2009.

4. Unity3D
It's very easy to get set in your ways when dealing with a ubiquitous platform such as Flash. With an over 90% penetration rate, one silently cringes when thinking of integrating another web platform on top of the Flash environment. That all gets thrown out the window after experiencing the pure awesomeness of the Unity3D plug-in. Well, O.K. The concerns are still there, but this is definitely something to keep an eye out for. As communication between Unity and Flash flourishes, this wil become standard for more robust 3D games and applications. I wouldn't be surprised if we see some sort of relationship between Adobe and Unity.

5. F.D.T.
It's easy to become an evangelist for FDT. The Powerflasher team is doing a great job of listening to the Flash community effectively which is great because I am one of those people that is quick to point out its occasional hiccups. 3.1 Standalone was a and the foundation for further updates. Soon we will see MXML support in early 2009 as well as the Obfuscator which the team is working on with Nicolas Cannasse (HaXe). FDT is looking to bridge the gap between the design process and the development process as well as enhance the management. With the work that is being done to provide MXML support, the FDT engine is no longer tied to a specific coding language. What this means is that special projects such as as UML functionality, or an FDT configuration specifically for designers, can be undertaken without modifying the core.

6. Adobe Flash CS4
Hard to go down the list without mentioning the recent release of Flash CS4. The addition of the new Vector class will help to speed iteration processes by providing strict/strong typing of an array. In many cases, casting an object's type in a parameter will speed complex calculations. Following that concept, by defining an array's type at the onset, the iteration focuses on accessing its contents instead of what it contains. You can find a good example of this at Alex Bustin's Blog. Also in recent news from Adobe, Alchemy (which allows you to compile C and C++ code into AS using llvm-gcc) will open the doors for many Actionscript developers. For ultimate cool factor, look out for the NES emulator running ROMS ported to AS3! (FlaCC – at the bottom) Also Catalyst (formerly known as Thermo), should hopefully make the relationship between designer and developer easier when it comes to wire-framing out concepts.

7. Red5
When it comes to a server solution for Flash deployment, there are pretty much two options. One is the Flash Media Server which starts at around $5000 and the other is the free and open source Red5. It features streaming of FLV and MP3, recording of client FLV streams, remoting, and shared objects just to name a few. An admin tool has been added in 0.6.3 as well as stream listeners. For 2009, the Red5 team is introducing Server-Side AS3. This will allow you to write code on the server without knowing Java extending the flexibility and accessibility of Red5 for developers. Whole applications can be developed on the server for things such as Social Networking, media manipulation, and so much more. Red5 is poised to hit the 1.0 version mark pretty soon which will help in making it even more competitive with Flash Media Server as stable platform.

8. AMFPHP
This overlaps with Red5 a tad, but I added it because it is something that I find quick and easy to use on a per project basis. Fairly straightforward as it provides communication between a PHP server and Flash applications. Another standard addition to this is Danny Patterson's AS3 Lightweight Remoting Framework.

9. Spring Actionscript/Prana
Prana is an Inversion of Control container for AS3. This topic very easily requires its own post, but in simplest terms, Prana lets you configure your Application's components using an external XML file and initializing them at runtime. For large scale projects this is important as it lets you define your framework and allow for changes and management of dependent classes. The best place to get an overview of how this works is here. You can also find an example of an AS3 only version. Because Prana uses a Spring complient XML structure, it's being made into a Spring Extension and being renamed "Spring Actionscript". Adding it to a family of other IoC frameworks on other platforms.

10. PopForge
Pop Forge has already gained a great deal of notoriety this year with Andre and Joa's exploit of the ByteArray hack. With the ability to write Byte level code directly to the Sound object in Flash 10, expect to see this library trimed down even further with more effects and added forms of sound manipulation. I'm looking forward to seeing signs of formant filtering as well as additive and spectral synthesis. How about routing L.F.O. control to other things like the Graphics class? Or better yet, routing graphical output to the envelope of a sound? Maybe some cross pollination of PixelBender with PopForge? Which of course brings me to my next item in the list…

11. Pixel Bender
Pixel Bender is Adobe's new kernal language used to manipulate pixels in new and creative ways. Pixel Bender runs on multiple Adobe products which opens up the ability to write uber-cool filters for static and motion graphics. Pixel Bender focuses heavily on the GPU to perform its tasks, making it much more efficient and capable of complex operations. Photoshop, Flash, and After Effects will all benefit from the experimental work being done with this tool and a number of innovative examples have already surfaced. Escher's Droste Effect is one such effect that "spiralizes" a circular pattern and even works with a video source. Another is the ability to do Ray Tracing and shading. I expect to see more of this trickle into Papervision and Bitmap processing libraries in the not so distant future.

Utilities and Helpful Approaches:

1. SWFObject 2.0
The standard for embedding anything with a swf at the end of the file path. 2.2 development has been started with plans to address OnHold/ FixedIn2.2AlphaX. Expect a number of Flash 10 enhancements to come shortly for things such as express installer, wmode, etc.

2. Unity Object
Awesome and useful example of how to communicate between a Unity3D app and Flash.

3. QueueLoader 3.1
My last shameless plug. I chose to add this because of the significant re-write of the utility and ease in which people can add their own extras. With the new structure in place, be on the lookout for more loadable items and useful preloading processes similar to the drawFrames (lets you draw the frames of an external SWF to an array of bitmaps) feature.

4. TextArea Paging
A great trick for detecting the overflow of a TextArea for spilling into another TextArea. Perfect for creating "news" style layouts and working around images.

5. FileReference Verification of File Type
Cool utility for detecting file types of uploaded assets using the FileReference class.

6. Libary Code Version Checking
Cool technique for checking the version of your code when initializing. Helps to keep track of what version of a library you are using in a project to avoid conflicts.

7. Object Pooling Class
Object Pooling is a technique for centralizing the management of instantiated objects. Having an object instantiated and ready for use can reduce bottlenecks and offers the ability to limit unique creation. This is perfect for particle engines as it's used above. If you've seen one of Seb Lee-Delisle's particle talks at a conference, then you've seen this in action with how he's recycling the particles.

8. SelectiveBitmapDraw
One other thing that gets Moses Gunesch really excited besides the mechanics of motion, is finding easy ways of compositing or capturing elements of a display hierarchy and manipulating them in fun ways. His SelectiveBitmapDraw Class lets you take a group of nested DisplayObjects and flag them for compositing into another Bitmap object. What makes this even cooler is that you can omit different items in the hierarchy. On top of that, you can use this with Papervision and apply it to DisplayObject3D items in your scene!

9. FLARToolKit
This is one of those things you need to see with a video. The FLARToolKit is used for creating "Augmented Reality" experiences. The way it works is by locking onto visual targets as reference points for creating motion and mapping points. Also check out the post of Mikkoh Haapoja's. A great video example can be found at today and tomorrow.

10. HiReS! SWF Stats
Mr. Doob has a well done dashboard for continuously outputting a running swf's performance. We've all used the frames-per-second bar, memory output meter, ms time in troubleshooting our applications. What his utility also gives you, is a visual graph of the data in real-time in a nice complete package.

11. Orchid
If you've heard of Saffron (Samuel Agesilas' Actionscript based UML utility for creating stub code in a graphical user interface), then you've heard of Orchid. Orchid is an open source UI framework that works using the concept of Signals and Slots. Saffron has long been shrouded in mystery and this is most likely the case due to the fact it was picked up by a well known software development company. Rumors that it was purchased by Microsoft popped up, then there have been ramblings of Adobe buying the code. Regardless of what the case is, having seen the interface work that Sam has done on Saffron, it's easy to get a sense of the capabilities and flexibility of the Orchid architecture.

In addition to the items above, there are a number of other interesting things worth mentioning. Animoto is a cool application that takes user submitted media, and creates a music video based on your settings and creative genius. Aviary is a group of software tools that let you edit images, generate color palettes, and visual effects. X-Ray is a fairly well known and already established debugging utility that makes tracking trace statements, errors, and resources much easier. John Grden was able to make some changes for the Flex crowd recently and I'm looking forward to seeing how this progresses even further.

So that's the list! Because there is so much exciting stuff coming in the new year, I'm considering adding a user submitted list. What do you think? Contact me and let's get another list going!

2

Flashbelt 2008 + Animation to Go + HydroTween + Papervision3D


Getting ready to leave for MN and I'm very excited to be a part of Moses' presentation at Flashbelt 2008! I will be providing a brief introduction to HydroTween. HydroTween is a multi-purpose tweening parser that runs on top of the Go framework. If you are familiar with ZigoEngine, Fuse, or Tweener, then using HydroTween should be a seamless transition. In this post, you will find the examples shown during the presentation. I've also put together an online version of what I will be showing. I was hoping to also include a demonstration of the Making Things controller running a tween on a servo, but my laptop isn't being cooperative. I will provide a separate post with an update on that as well as a library I am working on for controlling modules.

Back to the subject at hand, here are the 3 examples that I will be showing. The first is an example of generic tweening with most of the basic properties, filters, and image/hsb tweening. The second is a Fuse type example using navigation with multiple tweening properties running at once. The last is a Papervision3D example that is tweening a number of properties including brightness. Thanks to Andy Zupko's heroic efforts of merging the GreatWhite and Effects branches of Papervision together, we have alpha and the other none-positioning properties at our tweening disposal for 3D objects!

Here is the link to the presentation along with the examples. – Click into the SWF, then use the forward and back arrows to navigate.

I also urge you to check out my previous post that has useful information and source examples, along with changes and important features that have been added. HydroTween will call you renderer for automatic updating of your Papervision scene by registering with HydroTween using the init3D() method. One important new addition is the ability to pass a DisplayObject3D target into this init method for automatic use of the lookAt() method.

Here is the link to the previous post with more information about using HydroTween.

If you'd like to go directly to the examples:
Generic HydroTween
Fuse Style Tweening
Papervision3D – Clicking on an image will bring it up.

Looking forward to seeing everyone there!

And of course, the source! I have included everything in the examples, including the presentation!


Flashbelt2008 HydroTween Source and Examples

4

Papervision3D 2.0 + Go Tweening – Flipping Banner (Part 1)


Set up PapervisionTween to automatically render:

PapervisionTween.init(renderer, scene, camera, viewport);

Calling PapervisionTween to tween a plane:

var b:PapervisionTween = new PapervisionTween(_planeArray[0], {rotationY:0}, 0, 1, Quintic.easeInOut, onFlipDone);
b.start();

I've also included the PapervisionTween code in the post in addition to the source files below, but let's move on the flipping code.

Here's the Core class that calls the Flip class:

package com.hydrotik.bannerflip3d {
	/**
	 * @author Donovan Adams
	 * @version December 10, 2007
	 * @description Papervision Page flip example
	 * 
	 */
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.events.MouseEvent;
	import flash.net.URLRequest;
	import flash.net.navigateToURL;
 
	import com.hydrotik.bannerflip3d.Flip;
	import com.hydrotik.bannerflip3d.FlipEvent;
	import com.hydrotik.utils.XMLLoader;
	import com.hydrotik.utils.XMLLoaderEvent;
 
	import flash.system.Capabilities;	
 
	public class Core extends Sprite {
 
		private var _scope:MovieClip;
 
		private var _stage:Stage;
 
		private var _xml:XML;
 
		private var _url:String;
 
		private var _hit: Sprite;
 
		private var _targ : String;
 
		public function Core(scope:MovieClip, stage:Stage):void {
			_scope = scope;
			_stage = stage;
			var p:String;
			if (Capabilities.playerType == "External" || Capabilities.playerType == "StandAlone") {
				p = "../includes/admin/flippingbanner.xml";
			} else {
			    p = "/wp-content/flippingbanner2/includes/admin/flippingbanner.xml";
			}
			var xml:XMLLoader = new XMLLoader(p);
			xml.addEventListener(XMLLoaderEvent.COMPLETE, onXMLComplete);
			xml.addEventListener(XMLLoaderEvent.ERROR, onXMLError);
		}
 
		private function onXMLError(event : XMLLoaderEvent) : void {
			trace(event);
		}
 
		// --== Private Methods ==--
		private function onXMLComplete(event:XMLLoaderEvent):void {
			trace(":: onXMLComplete:");
			_xml = event.xml;
 
			var _oFlip:Flip = new Flip(_scope, _stage, this, event.xml.banner.children(), "", new int(_xml.attribute("seconds")));
			_oFlip.addEventListener(FlipEvent.COMPLETE, onCompleteHandler);
			_oFlip.addEventListener(FlipEvent.ON_FLIP, onFlipHandler);
 
			_hit = new Sprite();
			_hit.graphics.beginFill(0x660000, 0);
			_hit.graphics.drawRect(0, 0, _stage.stageWidth, _stage.stageHeight);
			_scope.addChild(_hit);
			_hit.addEventListener(MouseEvent.CLICK, onClickHandler);
 
			_hit.buttonMode = true;
			_hit.useHandCursor = true;
			_hit.mouseEnabled = true;
		}
 
		private function onClickHandler(event:MouseEvent):void {
			navigateToURL(new URLRequest(_url), _targ);
		}
 
		private function onCompleteHandler(event:FlipEvent):void {
			_url = event.link;
			_targ = event.targ;
		}
 
		private function onFlipHandler(event:FlipEvent):void {
			_url = event.link;
			_targ = event.targ;
		}
 
	}
}

Here's the updated Flip class using the Go tweening engine:

package com.hydrotik.bannerflip3d {
	/**
	 * @author Donovan Adams
	 * @version December 9, 2007
	 * @usage Example:<code></code>
	 * @description
	 * @history
	 * @sends
	 * @todo
	 * 
	 */
	import flash.display.*;
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	import flash.utils.setTimeout;
 
	import org.papervision3d.cameras.Camera3D;
	import org.papervision3d.core.proto.SceneObject3D;
	import org.papervision3d.events.FileLoadEvent;
	import org.papervision3d.materials.BitmapFileMaterial;
	import org.papervision3d.materials.ColorMaterial;
	import org.papervision3d.objects.DisplayObject3D;
	import org.papervision3d.objects.primitives.Plane;
	import org.papervision3d.render.BasicRenderEngine;
	import org.papervision3d.scenes.Scene3D;
	import org.papervision3d.view.Viewport3D;
 
	import com.hydrotik.go.PapervisionTween;
 
	import fl.motion.easing.*;
 
	import org.papervision3d.core.proto.MaterialObject3D;
 
	[Event(name="COMPLETE", type="com.hydrotik.bannerflip3d.FlipEvent")]
 
	[Event(name="ON_FLIP", type="com.hydrotik.bannerflip3d.FlipEvent")]
 
	public class Flip extends EventDispatcher {
 
		public static const VERBOSE:Boolean = true;
 
		private var _scope:Sprite;
 
		private var _stage:Stage;
 
		private var _oCore:*;
 
		private var _assetPath:String;
 
		private var _materialArray:Array;
 
		private var _planeArray:Array;
 
		private var _array:XMLList;
 
		private var _count:int = 0;
 
		private var _next:int;
 
		private var _prev:int;
 
		private var _loader:Sprite;
 
		private var _seconds:int;
 
		//New 2.0 Privates
 
		private var renderer:BasicRenderEngine;
 
		private var camera:Camera3D;
 
		private var viewport:Viewport3D;
 
		private var debug : Function;
 
		private var scene : Scene3D;
 
		private var white : MaterialObject3D;
 
		private var bg : Plane;
 
		public function Flip(scope:Sprite, stage:Stage, core:*, a:XMLList, assetPath:String = "../flashassets/", s:int = 10):void {
			debug = trace;
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			_scope = scope;
			_stage = stage;
			_oCore = core;
			_array = a;
			_assetPath = assetPath;
			_seconds = s;
			_materialArray = [];
			_planeArray = [];
 
			scene = new Scene3D();
			renderer = new BasicRenderEngine();
			camera = new Camera3D();
			camera.z = -100;
			viewport = new Viewport3D(500,300,true);
			viewport.alpha = 0;
 
			_scope.addChild(viewport);
 
			white = new ColorMaterial(0xFFFFFF);
 
			setTimeout(addedToStage, 100);
		}
 
		private function addedToStage():void{
			if(VERBOSE) debug("\n\n>> Flip.addedToStage(); - args: "+[]);
 
			_loader = new Sprite();
			_loader.graphics.beginFill(0x000000);
			_loader.graphics.drawRect(0, 0, 1, 4);
			_scope.addChild(_loader);
			_loader.x = (_stage.stageWidth/2) - 50;
			_loader.y = (_stage.stageHeight/2) - 2;
 
			for (var i:int = 0; i < _array.length(); i++) {
				_materialArray[i] = new BitmapFileMaterial(_array[i].attribute('src'));
				_materialArray[i].oneSide = true;
				_materialArray[i].smooth = true;
				_materialArray[i].addEventListener(FileLoadEvent.LOAD_PROGRESS, onFileProgress);
				_materialArray[i].addEventListener(FileLoadEvent.LOAD_COMPLETE, onFileComplete);
				_planeArray[i] = new Plane( _materialArray[i], 300, 156, 6, 6);
				scene.addChild(_planeArray[i]);
				_planeArray[i].name = i.toString();
				_planeArray[i].rotationY = -180;
			}
 
			// PapervisionTween is extending LinearGo. PapervisionTween is a custom extension using custom syntax, running on the Go system	
			// The init function passes the rendering info so that PapervisionTween can take care of updating the renderer
			PapervisionTween.init(renderer, scene, camera, viewport);
		}
 
		private function onFileProgress(event:FileLoadEvent):void {
			if(VERBOSE) debug("\t percentage: "+Math.round((event.bytesLoaded/event.bytesTotal)*100) + "%");
			var sec:Number = 100/_array.length();
			_loader.width = ((_count * sec) + ((event.bytesLoaded/event.bytesTotal) * sec));
		}
 
		private function onFileComplete(event:FileLoadEvent):void {
			if(VERBOSE) debug("complete!");
			//
			_count++;
			if (_count == _array.length()) {
				onImageQueueCompleteHandler();
			}
		}
 
		private function onImageQueueCompleteHandler():void {
 
			// PapervisionTween is extending LinearGo. PapervisionTween is a custom extension using custom syntax, running on the Go system		
			var l:PapervisionTween = new PapervisionTween(_loader, {alpha:0}, 0, .2, Quintic.easeInOut, loaderFade);
			l.start();
 
			// PapervisionTween is extending LinearGo. PapervisionTween is a custom extension using custom syntax, running on the Go system		
			var b:PapervisionTween = new PapervisionTween(_planeArray[0], {rotationY:0}, 0, 1, Quintic.easeInOut, onFlipDone);
			b.start();
 
			// PapervisionTween is extending LinearGo. PapervisionTween is a custom extension using custom syntax, running on the Go system		
			var c:PapervisionTween = new PapervisionTween(camera, {z:-100}, 0, 1, Quintic.easeInOut, onFlipDone);
			c.start();
 
			_next = 0;
 
			_count = -1;
 
			bg = new Plane(white,5120,2560,10,10);
			bg.y = -200;
			bg.z = 500;
			bg.pitch(0);
 
			scene.addChild(bg);
			dispatchEvent(new FlipEvent(FlipEvent.COMPLETE, _next, _array[0].attribute('link'), _array[0].attribute('target')));
 
			var myTimer:Timer = new Timer(_seconds * 1000);
			myTimer.addEventListener(TimerEvent.TIMER, timerHandler);
			myTimer.start();
		}
 
		private function flip(id:int):void {
			// PapervisionTween is extending LinearGo. PapervisionTween is a custom extension using custom syntax, running on the Go system				
			var a:PapervisionTween = new PapervisionTween(_planeArray[_next], {rotationY:180}, 0, 1, Quintic.easeInOut, onOldFlipDone);
			a.start();
 
			// Update Data
			_prev = _next;
			_next = (id == _array.length() - 1) ? 0 : id + 1;
			var url:String = _array[_next].attribute('link');
			var targ:String = _array[_next].attribute('target');
			trace(url, targ);
			dispatchEvent(new FlipEvent(FlipEvent.ON_FLIP, _next, url, targ));
 
			// PapervisionTween is extending LinearGo. PapervisionTween is a custom extension using custom syntax, running on the Go system		
			var b:PapervisionTween = new PapervisionTween(_planeArray[_next], {rotationY:0}, 0, 1, Quintic.easeInOut, onFlipDone);
			b.start();
 
			// PapervisionTween is extending LinearGo. PapervisionTween is a custom extension using custom syntax, running on the Go system		
			var c:PapervisionTween = new PapervisionTween(camera, {z:-350}, 0, .5, Quintic.easeIn, onCameraHalf);
			c.start();
		}
 
		private function onCameraHalf(event:Event = null):void {
			viewport.alpha 	= 1;
			var c:PapervisionTween = new PapervisionTween(camera, {z:-100}, 0, .5, Quintic.easeOut);
			c.start();
		}
 
		public function timerHandler(event:TimerEvent):void {
			if(VERBOSE) debug("timerHandler: " + event);
			_count = (_count == _array.length() - 1) ? 0 : _count + 1;
			flip(_count);
		}
 
		private function onFlipDone(event:Event = null):void {
			if(VERBOSE) debug("flip done!");
		}
 
		private function loaderFade(event:Event = null):void {
			viewport.alpha 	= 1;
			_scope.removeChild(_loader);
		}
 
		private function onOldFlipDone(event:Event = null):void {
			if(VERBOSE) debug("old flip done!");
			_planeArray[_prev].rotationY = -180;
		}
	}
}

And if you are curious here is the PapervisionTween extension of Go:

/**
 * Copyright (c) 2007 Moses Gunesch, MosesSupposes.com - Donovan Adams, blog.hydrotik.com
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
 
package com.hydrotik.go {
	import flash.display.DisplayObject;
 
	import org.fuseproject.go.items.LinearGo;
	import org.papervision3d.objects.DisplayObject3D;
 
	//import flash.geom.ColorTransform;
	//import flash.filters.BlurFilter;
	//import flash.geom.Point;	
 
	/**
	 * A basic example of how you could build a tween on LinearGo.
	 */
	public class PapervisionTween extends LinearGo {
 
		// -== Public Properties ==-
		public function get width() : Number {
			return _rotationY;
		}
 
		public function set width(value : Number) : void {
			if (_state == STOPPED)
				_rotationY = value;
		} 		
 
		public function get startWidth() : Number {
			return _startRotationY;
		}
 
		public function set startWidth(value : Number) : void {
			if (_state == STOPPED)
				_startRotationY = value;
		} 		
 
		public function get target() : DisplayObject {
			return _target;
		}
 
		public function set target(obj : DisplayObject) : void {
			if (_state == STOPPED)
				_target = obj;
		}
 
		// -== Protected Properties ==-
		protected var _target : *;
 
		protected var _rotationY : Number;
 
		private static var _viewport:*;
 
		private static var _camera:*;
 
		private static var _scene:*;
 
		private static var _renderer : *;
 
		private var _closure : Function;
 
		private var debug : Function;
 
		protected var _startRotationY : Number;
 
		protected var _changeRotationY : Number;
 
		protected var _startProps : Object = {};
 
		protected var _changeProps : Object = {};
 
		protected var _propsTo : Object = {};
 
 
		public static function init(renderer:*, scene:*, camera:*, viewport:*):void{
			_renderer = renderer;
			_scene = scene;
			_camera = camera;
			_viewport = viewport;
		}
 
		// -== Public Methods ==-
		public function PapervisionTween(
					target:* = null,
					propsTo:Object = null,
					delay:Number = NaN,
					duration:Number = NaN,
					easing:Function = null,
					closure:Function = null)
		{			
			super(delay, duration, easing);
			debug = trace;
			_target = target;
			if(closure != null) addCallback(closure);
			for (var prop in propsTo) { 
				switch (prop) {
					case "alpha":
						if(_target is DisplayObject){
							_propsTo[prop] = (propsTo[prop] != undefined) ? propsTo[prop] : _target[prop];	
						}
						if(_target is DisplayObject3D){
							if(propsTo[prop] != undefined){
								_propsTo[prop] = propsTo[prop];
							}else{
								_target.extra[prop] = new Number(1);
								_propsTo[prop] = _target.extra[prop] = _target.extra[prop];
							}
						}
						break;
					default:
						_propsTo[prop] = (propsTo[prop] != undefined) ? propsTo[prop] : _target[prop];
				}
			}
		}
 
		override public function start( ) :Boolean {
			if (!_target) return false;
			var prop:String;
			for (prop in _propsTo) { 
				switch (prop) {
					case "alpha":
						if(_target is DisplayObject){
							_startProps[prop] = _target[prop];
						}
						if(_target is DisplayObject3D){
							trace("start: "+_target.extra[prop]);
							_startProps[prop] = _target.extra[prop];	
						}
						break;
					default:
						_startProps[prop] = _target[prop];
				}
			}
 
			if (useRelative) {
				for (prop in _propsTo) { 
				    _changeProps[prop] = _propsTo[prop];
				}
			}
			else {
				for (prop in _propsTo) { 
				    _changeProps[prop] = (_propsTo[prop] - _startProps[prop]); //_propsTo[prop];
				}
			}
 
			return (super.start());
		}
 
		//TODO add alpha tweening syntax when released in 2.0 update
		override protected function onUpdate(type:String) : void {
			for (var prop in _propsTo) { 
				switch (prop) {
					case "alpha":
						if(_target is DisplayObject3D){
							//var val:Number = super.correctValue(_startProps[prop] + _changeProps[prop] * _position);
							//_target.material.bitmap.colorTransform(_target.material.bitmap.rect, new ColorTransform(1, 1, 1, val, 0, 0, 0, 0));
							//_target.extra[prop] = val;
							debug("Current version of Pv3D does not support alpha tweening");
						}
						if(_target is DisplayObject) _target[prop] = super.correctValue(_startProps[prop] + _changeProps[prop] * _position);
						break;
					default:
						_target[prop] = super.correctValue(_startProps[prop] + _changeProps[prop] * _position);
				}
			}
			if(_target is DisplayObject3D) _renderer.renderScene(_scene,_camera,_viewport);
		}
 
	}
}

I plan on adding effects as well as the alpha property when 2.0 is able to support that. Shadows, layer effects, and more still to come!


Papervision 2.0 Flipping Banner Source Part 1

0

Papervision 2.0


Had a great time at the Papervision 2.0 seminar with John Grden and Andy Zupko here in NYC. Lot of eager people braving the cold snowy weather. It was slow at times trying to get everyone going on Flex. This gave me time to get the demos working in AS3 only FDT projects. Hopefully with John's and Andy's blessing I can put those demos here on the blog :)

6

AS3 Papervision + Sound Visualizer + Line3D + Tweener – Part 2 FF07


So here's my Flash Forward inspired piece!

Once again used Andy's great Line3D class and gave it a Flash Forward 07 twist.

package com.hydrotik {
 
	import flash.events.Event;
	import flash.display.*;
	import flash.net.URLRequest;
	import flash.media.Sound;
	import flash.media.SoundChannel;
	import flash.media.SoundMixer;
	import flash.utils.ByteArray;
	import caurina.transitions.Tweener;
	import org.papervision3d.core.proto.*;
	import org.papervision3d.core.geom.*;
	import org.papervision3d.scenes.*;
	import org.papervision3d.cameras.*;
	import org.papervision3d.objects.*;
	import org.papervision3d.materials.*;
 
	public class Hydro3D extends Sprite {
 
		private static const LOOP:String = "../flashassets/mp3/jens_buchert.mp3";
 
		private const STAGE_WIDTH		:Number = 600;
		private const STAGE_HEIGHT		:Number = 300;
		private const ANIMATION_TIME	:Number = 1;
		private const ANIMATION_TYPE	:String = "easeoutquad";
		private const MULT				:int = 10;
		private var controlPoints		:Array;
		private var itemArray			:Array;
		private var trailArray			:Array;
		private var currTrailArray		:Array;
		private var lineArray			:Array;
		private var count				:int = 0;
		private var container 			:Sprite;
		private var scene     			:MovieScene3D;
		private var camera    			:Camera3D;
		private var sc					:SoundChannel;
		private var s					:Sound;
		private var lines	  			:Line3D;
 
		public function Hydro3D():void {
 
			controlPoints = [];
			itemArray = [];
			trailArray = [];
			currTrailArray = [];
			lineArray = [];
 
			s = new Sound();
			s.load(new URLRequest(LOOP));
			sc = s.play(0, 1000);
 
			//container
			container = new Sprite();
			container.cacheAsBitmap = true;
			addChild( container );
			container.x = STAGE_WIDTH/2;
			container.y = STAGE_HEIGHT/2;
 
			//scene
			scene = new MovieScene3D( container );
 
			//camera
			camera = new Camera3D();
			camera.z = -200;
 
			addEventListener( Event.ENTER_FRAME, onEnterFrame );
		}
 
 
		private function onEnterFrame( event: Event ):void {
			camera.x +=((container.mouseX*10) - camera.x) * 0.005;
			camera.y +=((container.mouseY*10) - camera.y) * 0.005;
 
			var bytes:ByteArray = new ByteArray();
			SoundMixer.computeSpectrum(bytes, false, 0);
 
			var amp:Number = ((sc.leftPeak + sc.rightPeak)/2);
 
			lineArray[count] = new Line3D([new Vertex3D(-128, 0, -(count * MULT))], rgbToHex(count/4, count/6, count), 1, 1);
			scene.addChild(lineArray[count]);
 
			for(var i:int = 0; i < 256; i++){
				var v:Vertex3D = new Vertex3D((i*2) - 128, bytes.readFloat() * 300, -(count * MULT));
				lineArray[count].addVertex(v);
			}
 
			Tweener.addTween(lineArray[count], {
						alpha:0,
						time:ANIMATION_TIME,
						transition:ANIMATION_TYPE,
						onComplete:removeLine,
						onCompleteParams:[lineArray[count]]
					});
 
			scene.renderCamera( camera );
			count = (count < 50) ? count + 1 : 0;
		};
 
		private function removeLine(l:Line3D = null):void{
			scene.removeChild(l);
		}
 
		public function rgbToHex(uR:uint, uG:uint, uB:uint):int{
            var uColor:uint;
            uColor =  (uR & 255) << 16;
            uColor += (uG & 255) << 8;
            uColor += (uB & 255);
            return uColor;
        }
 
	}
}

I didn't do anything with the amplitude but I left it in there if you decide you want to play with it. It's somewhat processor intensive. I wish external mp3's would loop. You'd think Adobe would have addressed that by now. Because of that, you'd want to attach it from your library, but I think it's ok for testing. Helps you find a good loop that gives you good results when playing with a visualizer. Just overwrite the mp3 file or switch the path.

Once again the loop I'm using:

Jens Buchert
The music is the song "Mélange Eléctrique" from Jens Buchert's album Spa Lounge. Great downtempo album.


Lines3D Part 2 Source

15

Papervision + Tweener + AS3 – Flipping Banner


UPDATE: Since I'm having problems with the SWF embedding, download the files to preview. Also be sure to check out the newer version with PV3D 2.0

Here's a little simple and practical application I had to put together for work using papervision. Nothing to write home about. Just a real world example that proves how easy it is to add papervision to your daily workflow. All this does is load a set of images from an XML file and papervision transitions from one to the other by flipping the plane using Tweener.

Core class:

package com.hydrotik.pageflip{
 
	/**
	 * @author Donovan Adams
	 * @version Sept 16, 2007
	 * @description Papervision Page flip example
	 * 
	 */
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.net.navigateToURL;
	import flash.display.Sprite;
	import flash.display.MovieClip;
	import flash.display.Stage;
	import flash.display.DisplayObject;
	import flash.display.Shape;
	import flash.text.StyleSheet;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.text.TextFieldAutoSize;
	import flash.filters.BlurFilter;
 
	import caurina.transitions.Tweener;
 
	import com.hydrotik.utils.XMLManager;
	import com.hydrotik.pageflip.Flip;
	import com.hydrotik.pageflip.FlipEvent;
 
	public class Core extends Sprite {
 
		private var _scope:MovieClip;
 
		private var _stage:Stage;
 
		private var _url:String;
 
		private var _xml:XML;
 
		private var url:String;
 
		private var _hit:Sprite;
 
		public function Core(scope:MovieClip, stage:Stage):void {
			_scope = scope;
			_stage = stage;
			_url = _scope.loaderInfo.url;
			var xml:XMLManager = new XMLManager("../includes/admin/flippingbanner.xml");
			xml.addEventListener("evtXMLLoaded", onXMLComplete);
		}
 
 
		// --== Private Methods ==--
		private function onXMLComplete(event:Event):void {
			trace(":: onXMLComplete:");
			_xml = event.target.xml;
 
			var _oFlip:Flip = new Flip(_scope, _stage, this, _xml.banner.children(), _xml.attribute("seconds"));
			_oFlip.addEventListener(FlipEvent.COMPLETE, onCompleteHandler);
			_oFlip.addEventListener(FlipEvent.ON_FLIP, onFlipHandler);
 
			_hit = new Sprite();
			_hit.graphics.beginFill(0x660000, 0);
			_hit.graphics.drawRect(0, 0, 300, 156);
			_scope.addChild(_hit);
			_hit.addEventListener(MouseEvent.CLICK, onClickHandler);
 
			_hit.buttonMode = true;
			_hit.useHandCursor = true;
			_hit.mouseEnabled = true;
		}
 
		private function onClickHandler(event:MouseEvent):void {
			trace("url: " + url);
			var request:URLRequest = new URLRequest(url);
			try {
				navigateToURL(request, "_self");
			} catch (e:Error) {
				// handle error here
			}
		}
 
		private function onCompleteHandler(event:FlipEvent):void {
			trace(event);
			url = event.url;
		}
 
		private function onFlipHandler(event:FlipEvent):void {
			trace(event);
			url = event.url;
		}
 
	}
}

Flipping code:

package com.hydrotik.pageflip{
 
	/**
	 * @author Donovan Adams
	 * @version July 10, 2007
	 * @usage Example:<code></code>
	 * @description
	 * @history
	 * @sends
	 * @todo
	 * 
	 */
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.MouseEvent;
	import flash.filters.BitmapFilter;
	import flash.filters.BitmapFilterQuality;
	import flash.filters.BlurFilter;
	import flash.utils.Timer;
	import flash.events.TimerEvent;
	import flash.display.*;
	import org.papervision3d.cameras.FreeCamera3D;
	import org.papervision3d.core.*;
	import org.papervision3d.core.geom.Vertex3D;
	import org.papervision3d.materials.InteractiveMovieAssetMaterial;
	import org.papervision3d.materials.BitmapFileMaterial;
	import org.papervision3d.materials.ColorMaterial;
	import org.papervision3d.objects.Plane;
	import org.papervision3d.scenes.InteractiveScene3D;
	import org.papervision3d.events.InteractiveScene3DEvent;
	import org.papervision3d.events.FileLoadEvent;
	import org.papervision3d.utils.*;
 
	import caurina.transitions.Tweener;
 
	import com.hydrotik.pageflip.FlipEvent;
 
	public class Flip extends EventDispatcher {
 
		private var _scope:Sprite;
 
		private var _stage:Stage;
 
		private var _oCore:*;
 
		private var _assetPath:String;
 
		private var container:Sprite;
 
		private var scene:InteractiveScene3D;
 
		private var camera:FreeCamera3D;
 
		private var _materialArray:Array;
 
		private var _planeArray:Array;
 
		private var _array:XMLList;
 
		private var _count:int = 0;
 
		private var _next:Plane;
 
		private var _prev:Plane;
 
		private var _shadowPlane:Plane;
 
		private var _loader:Sprite;
 
		private var url:String;
 
		private var _id:int;
 
		private var _seconds:int;
 
		public function Flip(scope:Sprite, stage:Stage, core:*, a:XMLList, assetPath:String = "../flashassets/", s:int = 10):void {
			_scope = scope;
			_stage = stage;
			_oCore = core;
			_array = a;
			_assetPath = assetPath;
			_seconds = s;
			_materialArray = [];
			_planeArray = [];
 
			// Add Container
			container = new Sprite();
			container.x = stage.stageWidth/2;
			container.y = stage.stageHeight/2;
			_scope.addChild( container );
 
			scene = new InteractiveScene3D( container );
 
			camera = new FreeCamera3D();
			camera.z = -500;
 
			_loader = new Sprite();
			_loader.graphics.beginFill(0x000000);
			_loader.graphics.drawRect(0, 0, 1, 4);
			_scope.addChild(_loader);
			_loader.x = (stage.stageWidth/2) - 50;
			_loader.y = (stage.stageHeight/2) - 2;
 
			var colorMaterial:ColorMaterial = new ColorMaterial(0x000000, .2);
			_shadowPlane = new Plane( colorMaterial, stage.stageWidth, 50, 6, 6);
			_shadowPlane.y = -150;
			_shadowPlane.z = 50;
			_shadowPlane.rotationX = -90;
			_shadowPlane.rotationY = -180;
			scene.addChild(_shadowPlane);
 
			var filter:BitmapFilter = getBitmapFilter();
			var myFilters:Array = new Array();
			myFilters.push(filter);
			_shadowPlane.container.filters = myFilters;
			_shadowPlane.container.alpha = 0;
 
			for (var i:int = 0; i < _array.length(); i++) {
				_materialArray[i] = new BitmapFileMaterial(_array[i].attribute('src'));
				_materialArray[i].doubleSided = false;
				_materialArray[i].smooth = true;
				_materialArray[i].addEventListener(FileLoadEvent.LOAD_PROGRESS, onFileProgress);
				_materialArray[i].addEventListener(FileLoadEvent.LOAD_COMPLETE, onFileComplete);
				_planeArray[i] = new Plane( _materialArray[i], stage.stageWidth, stage.stageHeight, 6, 6);
				scene.addChild( _planeArray[i] );
				_planeArray[i].name = i.toString();
				_planeArray[i].rotationY = -180;
				_planeArray[i].container.alpha = 0;
			}
 
 
			// render the scene once
			scene.renderCamera( camera );
		}
 
 
 
		private function flip(id:int):void {
			Tweener.addTween(_next.container, {
				alpha:0,
				time:1,
				transition:"easeoutquint"
			});
			Tweener.addTween([_next, _shadowPlane], {
				rotationY:180,
				time:1,
				transition:"easeoutquint",
				onComplete:onOldFlipDone
			});
 
			// Update Data
			_prev = _next;
			_id = (id == _array.length() - 1) ? 0 : id + 1;
			_next = _planeArray[_id];
			url = _array[_id].attribute('link');
 
			dispatchEvent(new FlipEvent(FlipEvent.ON_FLIP, _id, _next.container, url));
 
			Tweener.addTween(_next.container, {
				alpha:1,
				time:1,
				transition:"easeoutquint"
			});
			Tweener.addTween([_next], {
				rotationY:0,
				time:1,
				transition:"easeoutquint",
				onUpdate:draw,
				onComplete:onFlipDone
			});
			Tweener.addTween(camera, {
				z:-100,
				_bezier:[{z:-350}, {z:-100}],
				time:2,
				transition:"easeoutquint"
			});
		}
 
 
		private function onFileProgress(event:FileLoadEvent):void {
			trace("\t percentage: "+Math.round((event.bytesLoaded/event.bytesTotal)*100) + "%");
			var sec:Number = 100/_array.length();
			_loader.width = ((_count * sec) + ((event.bytesLoaded/event.bytesTotal) * sec));
		}
 
		private function onFileComplete(event:FileLoadEvent):void {
			trace("complete!");
			scene.renderCamera( camera );
			_count++;
			if (_count == _array.length()) {
				onImageQueueCompleteHandler();
			}
		}
 
		private function onImageQueueCompleteHandler():void {
			dispatchEvent(new FlipEvent(FlipEvent.COMPLETE, 0, _planeArray[0].container, _array[0].attribute('link')));
			Tweener.addTween(_loader, {
				alpha:0,
				time:.2,
				transition:"easeoutquint",
				onComplete:loaderFade
			});
 
 
			trace("** papervision queue complete!!");
			Tweener.addTween([_planeArray[0].container, _shadowPlane.container], {
				alpha:1,
				time:1,
				transition:"easeoutquint"
			});
			Tweener.addTween([_planeArray[0], _shadowPlane], {
				rotationY:0,
				time:1,
				transition:"easeoutquint",
				onUpdate:draw,
				onComplete:onFlipDone
			});
			Tweener.addTween(camera, {
				z:-100,
				time:1,
				transition:"easeoutquint"
			});
			_next = _planeArray[0];
 
			_count = -1;
 
			var myTimer:Timer = new Timer(_seconds * 1000);
			myTimer.addEventListener(TimerEvent.TIMER, timerHandler);
			myTimer.start();
		}
 
		public function timerHandler(event:TimerEvent):void {
			trace("timerHandler: " + event);
			_count = (_count == _array.length() - 1) ? 0 : _count + 1;
			flip(new Number(_count));
		}
 
		private function draw():void {
			scene.renderCamera( camera );
		}
 
		private function onFlipDone():void {
			trace("flip done!");
 
		}
 
		private function loaderFade():void {
			_scope.removeChild(_loader);
		}
 
		private function onOldFlipDone():void {
			trace("old flip done!");
			_prev.rotationY = -180;
			_shadowPlane.rotationY = 0;
		}
 
		private function getBitmapFilter():BitmapFilter {
			var blurX:Number = 5;
			var blurY:Number = 5;
			return new BlurFilter(blurX,blurY,BitmapFilterQuality.HIGH);
		}
	}
}

Papervision is constantly going through new revs so keep in mind this is not the most recent. You'll see the Flip custom event, and a little XML loading utility in the source. Note that the Core file is just the main class. It could be your main timeline for all intents and purposes. Also the loader calculates the total images. I added a shadow plane just for a slight touch but that would lend itself to a white background and fixed banner sizes. A little breathing room for the shadow would be good if you wanted to enhance the effect. It's just a jumping off point for more, so have fun! :)

Like I said, nothing too fancy. Enjoy!


Papervision Flipping Banner Source

4

Papervision 3D + Line3D + Tweener – Part 1


Here's my initial experiment using the new Line3D class addition to papervision from Andy Zupko. My example is in its early stages, needs some fade and remove functionality, possibly use of a Null 3D object for the lines to draw from,. Becuase of this it has obvious performance issues after it draw for a bit. Hence the "Part 1″ ;)

Update – I decided to remove the example as it bogs down the page if it's running for a while. It's in dire need of incremental removal and garbage collection.

I don't think the Line3D object has been merged into the regular updates to pv3d, but you can get the class in the source files below and from Andy's site as well.

Back Story: I came up with an AS3 version of a 2D version of this inspired by Felix Turner and his Bezier Tween AS2 Class. I'll post the code for that soon since I seem to be in the spirit of doing everything backwards these days.

Here's the code:

package com.hydrotik {
 
	import flash.events.Event;
	import flash.display.MovieClip;
	import flash.display.Stage;
	import flash.display.Sprite;
	import caurina.transitions.Tweener;
	import com.ascb.util.NumberUtilities;
	import org.papervision3d.core.proto.*;
	import org.papervision3d.core.geom.*;
	import org.papervision3d.scenes.*;
	import org.papervision3d.cameras.*;
	import org.papervision3d.objects.*;
	import org.papervision3d.materials.*;
 
	public class Hydro3D extends Sprite {
 
		private const STAGE_WIDTH		:Number = 500;
		private const STAGE_HEIGHT		:Number = 300;
		private const ANIMATION_TIME	:Number = 8;
		private const ANIMATION_TYPE	:String = "easeoutquad";
		private var controlPoints		:Array;
		private var itemArray			:Array;
		private var trailArray			:Array;
		private var currTrailArray		:Array;
		private var lineArray			:Array;
		private var count				:int = 0;
		private var container 			:Sprite;
		private var scene     			:MovieScene3D;
		private var camera    			:Camera3D;
 
 
		public function Hydro3D():void {
 
			controlPoints = [];
			itemArray = [];
			trailArray = [];
			currTrailArray = [];
			lineArray = [];
 
 
			//container
			container = new Sprite();
			addChild( container );
			container.x = STAGE_WIDTH/2;
			container.y = STAGE_HEIGHT/2;
 
			//scene
			scene = new MovieScene3D( container );
 
			//camera
			camera = new Camera3D();
			camera.z = -200;
 
			//Dot color
			var color:ColorMaterial = new ColorMaterial(0x666666, .5);
 
			for (var i:uint = 0; i < 2; i++) {
 
				trailArray[i] = new Sphere(color, 1, 2, 2);
				scene.addChild(trailArray[i]);
 
				itemArray[i] = new Sphere(color, 5, 5, 10);
				scene.addChild(itemArray[i]);
 
				lineArray[i] = new Line3D([new Vertex3D(0, 0, 0), new Vertex3D(0, 0, 0)], 0x333333, 1, 1);
				scene.addChild(lineArray[i]);
			}
 
			addEventListener( Event.ENTER_FRAME, onEnterFrame );
 
			moveIt();
		}
 
		private function moveIt():void {
			var deltaX:Number = NumberUtilities.random(-800, 800);
			var deltaY:Number = NumberUtilities.random(-800, 800);
			var deltaZ:Number = NumberUtilities.random(-800, 800);
 
			for (var i:uint = 0; i < itemArray.length; i++) {
 
				var trailList:Array = [];
				for (var q:int = 0; q < 10; q++) {
					trailList.push({
						x:NumberUtilities.random(0, STAGE_WIDTH),
						y:NumberUtilities.random(0, STAGE_HEIGHT),
						z:NumberUtilities.random(-200, 200)
					});
				}
				Tweener.addTween(trailArray[i], {
					x:deltaX,
					y:deltaY,
					z:deltaZ,
					_bezier:trailList,
					time:ANIMATION_TIME,
					transition:ANIMATION_TYPE
				});
 
 
				var bezierList:Array = [];
				for (var v:int = 0; v < 10; v++) {
					bezierList.push({
						x:NumberUtilities.random(0, STAGE_WIDTH),
						y:NumberUtilities.random(0, STAGE_HEIGHT),
						z:NumberUtilities.random(-200, 200)
					});
				}
 
				if(i == itemArray.length - 1){
					Tweener.addTween(itemArray[i], {
						x:deltaX,
						y:deltaY,
						z:deltaZ,
						_bezier:bezierList,
						time:ANIMATION_TIME,
						transition:ANIMATION_TYPE,
						onComplete: moveIt
					});
				}else{
					Tweener.addTween(itemArray[i], {
						x:deltaX,
						y:deltaY,
						z:deltaZ,
						_bezier:bezierList,
						time:ANIMATION_TIME,
						transition:ANIMATION_TYPE
					});
				}
 
			}
 
		}
 
		private function onEnterFrame( event: Event ):void {
			camera.x +=((container.mouseX*10) - camera.x) * 0.005;
			camera.y +=((container.mouseY*10) - camera.y) * 0.005;
 
 
			for (var i:int = 0; i < itemArray.length; i++) {
				lineArray[i].addVertex(new Vertex3D(trailArray[i].x, trailArray[i].y, trailArray[i].z));
			}
 
			scene.renderCamera( camera );
		};
 
	}
}

I'm almost positive there is a smoother and more efficient way to do this mathematically but I'm no math whiz. So in the meantime…


Lines3D Source