Molehill Away3D Dancing Fish Demo Part 1

Requires Install of Flash Player “Stage3D”

Download Example / Launch Demo

Away3D specifically broomstick really cleans up the competition should look out. It is easy to use and is ridiculously fast! The upcoming flash player is such a leap from the previous versions its really quite astounding. So if you haven’t downloaded that latest flash sdk and plugged it into your flash builder you are really missing out on a great deal. With Flash Player 11 support on mobile it will be a big deal not to mention all the new cool 3D capabilities that will run on literally any desktop and most mobile devices! It will allow you to quickly create games and interactive experiences and easily share them and sell them trough app stores so the time to learn it is truly now! Be proactive build today for tomorrow. You won’t have to purchase multiple product suites to accomplish your goal with web premium you can simply get it done quickly. I have been waiting for this product for awhile and I am really looking forward to taking full advantage of it as a developer! As a teenager I can remember downloading Wolfenstein off of a BBS and running it on my 486 that ran windows and dos-shell. I thought it was the coolest thing on earth! I spent coupious amounts of time palying it because it was the first true 3D experince on copmuters and it was shareware! In the past we have been able to create compleling 3D experinces on flash but never before to this extent! Stage3D formerly Molehill will allow us as developers to build emmersive interactive enviorments that are more engaging than Quake3 because it scales not to mention we have a rather large amount of libraries at our finger tips like the Hype Framework, TweenLite, Tweener, JigLib, etc… We also have access to manipulating audio and video the browser currently only dreams of. These libraries help us accomplish what ever goal we may have. I am by no means a pro with Away3D although I love using it and I have learned a great deal from it.

So anyway enough lets take Away3D out of the box and have some fun with it! What am I doing? Playing with the cloning ability, the Bloom filter, and making the fish dance to audio with the Hypeframework and trying to absolutely crush your browser while having fun. Also if you didn’t know one of the new features of flash player 11 aka Stage3D formerly known as Molehill is native JSON which is in my opinnion kind of hot! So lets let the player do it’s work and have fun with it! The demo I am displaying would have grinded your browser to a complete halt in the past you can see now that it is lighning fast and I am sure my quickly written code could be optimized so check it out! It doesn’t crash your browser! It also will parse a twitter object that utilizes the search query for Molehill if it fails it does so gracefully please keep in mind this is alpha software.

The Code:

package
{
	// Away 3D broomstick
	import away3d.cameras.Camera3D;
	import away3d.cameras.lenses.PerspectiveLens;
	import away3d.containers.ObjectContainer3D;
	import away3d.containers.View3D;
	import away3d.core.base.Object3D;
	import away3d.debug.AwayStats;
	import away3d.entities.Mesh;
	import away3d.events.LoaderEvent;
	import away3d.events.MouseEvent3D;
	import away3d.filters.BloomFilter3D;
	import away3d.filters.MotionBlurFilter3D;
	import away3d.library.AssetLibrary;
	import away3d.loaders.AssetLoader;
	import away3d.loaders.Loader3D;
	import away3d.loaders.parsers.AWDParser;
	import away3d.materials.BitmapMaterial;
	import away3d.primitives.Sphere;
    // Lee's library
	import com.theflashblog.utils.Math2;
	// flash stuff
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.MouseEvent;
	import flash.geom.Vector3D;
	import flash.media.Sound;
	import flash.media.SoundChannel;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.net.URLRequestMethod;
	import flash.net.navigateToURL;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	// greensock tweenlite 
	import gs.TweenLite;
	// hype because it is awesome
	import hype.extended.behavior.FunctionTracker;
	import hype.extended.layout.GridLayout;
	import hype.framework.sound.SoundAnalyzer;
	
	[SWF(width="900", height="600", frameRate="60", backgroundColor="#000000")]
	public class tweetank extends Sprite
	{
		private var _view : View3D;
		private var _loader : Loader3D;
		private var urlRequestContainer:Array = new Array();
		[Embed(source="assets/models/Sphere01-node.png")]
		private var Ocean : Class;
		private var mesh:Mesh = new Mesh();
		private var material : BitmapMaterial = new BitmapMaterial(new Ocean().bitmapData);
		private var fishy:Object = new Object();
		public var camera:Camera3D;
		public  var fishArr:Array = new Array(); 
		private var origin:Vector3D=new Vector3D(0,0,0);
		private var OceanSphere : Sphere;
		public var soundAnalyzer:SoundAnalyzer;
		public var sound:Sound;
		private var musicChannel;
		public var xMove:FunctionTracker;
		public var xScaleTracker:FunctionTracker;
		public var yScaleTracker:FunctionTracker;
		public var zScaleTracker:FunctionTracker;
		private var loaderJSON:URLLoader;
		private var _motionBlur : MotionBlurFilter3D;
		
		public function tweetank()
		{
        	// lets have some fun with away3D
			_view = new View3D();
			_view.width = stage.width;
			_view.height = stage.height;
			_view.camera.z = -1000;
			camera = _view.camera;
			camera.lens = new PerspectiveLens();
			camera.lens.far = 8000;
			addChild(_view);
			_view.mouseEnabled = true;
			_view.filters3d = [ new BloomFilter3D(100, 100, .5, 2, 1) ];
			this.addEventListener(Event.ENTER_FRAME, handleEnterFrame);
			moveCamera();
			// init the HYPE sound analyzer
			soundAnalyzer = new SoundAnalyzer();
			soundAnalyzer.start();
			// load the json vars
			loaderJSON = new URLLoader(
		    new URLRequest("http://search.twitter.com/search.json?q=molehill"));
			loaderJSON.addEventListener(Event.COMPLETE, onLoaded);
		}
		
		// lets make some stuff move!
		private function moveCamera():void
		{
			TweenLite.to
				(
					camera, 
					4, 
					{
						x: Math2.rand(-800, 800),
						y: Math2.rand(-400, 400),
						z: 1400 + Math2.rand(-2800, 0),
						delay: 2,
						onComplete: moveCamera,
						onUpdate: onCameraMove
					}
				);
			
		}
		
		private function onCameraMove():void
		{
        	// hone in on the school of fish shall we
			try{
			var fishArrVector:Vector3D = new Vector3D(fishArr[5].x,fishArr[5].y,fishArr[5].z );
			camera.lookAt( fishArrVector );
			}catch(e:Error){
				trace(e);
				
			}
		}
		
		
		
		
		private function onComplete(e:LoaderEvent):void{
			var fishyLength:Number;
            // I will perfect the JSON later sorry kind of lazy.
            // Also kind of trying to donkey punch your browser how is it holding up?? Well!
			try{
				fishyLength = fishy.results.length;
			}catch(e:Error){
				fishyLength = 15;
				var twitterFail:TextField = new TextField();
				twitterFail = new TextField();
			    var _label_format : TextFormat = new TextFormat();
				twitterFail.defaultTextFormat = _label_format;
				twitterFail.autoSize = TextFieldAutoSize.RIGHT; 
				twitterFail.text = 'Sorry Parsing of the Twitter feed Failed:(  It is an alpha flash player version.';
				twitterFail.x = 200;
				twitterFail.y = 2;
				twitterFail.selectable = false;
				addChild(twitterFail);
			}
			for(var i:uint = 0; i

Download Example / Launch Demo

When I look at something like three.js I also love it too and I know that many of its greatest abilities were borrowed form the flash camp! Open source gives way to more open source. The community of developers often learn from the code that is in the open source community and this allows for future innovations! You can see the similarties between the three.js code base and projects like away3d. It is amazing how many options we have as developers today. With Molehill, webGL, and Silverlight all going at it we as developers profit! Three.js was prominetly displayed on at google IO and the Ro.me project is simply amazing check it out! I am anxious to see where webGL will take us. You can view the interactive film that Chris Milk and Google Developer Aaron Koblin

What is 3 Dreams of Black?

View Ro.me

Molehill is a mountain it is a big deal for developers and a quantum leap for developers! If you haven't checked it out yet you should! Why? Probably because it is supported on Android devices and will be supported on many platforms beyond just Android. It also appears to run quickly and degrade gracefully for mobile devies and the desktop. Not to mention you can use all of your favorite AS3 libraries with it! So needless to say I am exceptionally excited about it as a developer! I purchase Adobe products and love them and enjoy using them! I think Unity3D is a really cool technology and their is a great deal to be said for it. I live in the mid west and I pinch my pennies, I spend more on my Apple than I do on my car and I mean that in a literal way. That being said I am not a fan of purchasing multiple license for the same product. I also like to program and the thought of one program doing all the dirty work for me takes the challenge and learning experience away. Although with business their are some cases where that scenario is simply a necessity. I also like open source because it helps developers like myself learn and closed technology seems to pin you in a corner. I have been making lots of webGL demos lately and I am equally excited about Molehill/Stage3D because I can utilize tools I already use and own to produce outstanding web and mobile experiences! It has alway been essential for Flash to be ubiquitous and I am confident that it will strive ahead the new features in the Flash player and Air are truly innovative. I also love to use other technologies and explore new ideas. I firmly believe that competition keeps people sharp and companies striving for innovation and that is essential because the consumer wins in this situation every time! So I am really excited about the future Windows Vs. Google Vs. Apple it means we all win! I am also looking forward to playing with the windows phone Silverlight5 looks cool!

← Previous post

Next post →

2 Comments

  1. hi、my name is william, my project need to  use ayaw3d 4.0.i hope you give me any advice.
    thank you. my friend.

  2. Their latest codebase is available on github https://github.com/away3d . I updated one of my examples http://i-create.org/2011/06/12/bsp-map-in-threejs-and-away3d-using-molehill-and-webgl/ . You should also check out the new physics library for away3d used with jiglib here is a really good example of it in action -> http://blog.muzerly.com/?tag=jiglib all my examples were compiled with Flash Builder but I believe the it can all be done with flash develop if that’s your preferred ide download the latest player and sdk http://labs.adobe.com/technologies/flashplatformruntimes/flashplayer11-2/ I will be posting another away3D example with physics in the near future hope that is enough to get you looking in the right spots.

Leave a Reply