Add

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

The Discussion

see what everyone is saying

  • C4RL05 September 21st, 2007 at 8:25 am #1

    Excellent demo and great music choice. Look forward to meet you here in Boston.

  • fritz October 1st, 2007 at 6:45 am #2

    Sorry I can't see anything! Windows XP, tried both IE7 and FireFox, Flash Player 9,0,47,0

  • djdonovan October 1st, 2007 at 9:18 am #3

    There is a bug in the flash player with IE7. The onComplete loading event doesn't fire. I was lazy and forgot to update the loader in this example using only an onEnterframe event to determine progress. If you remove the complete event and do a gotoAndPlay(2) then you should be fine. I plan on posting an example of that soon, but it's easy to find and is a known issue.

  • [...] Donovan Adams: 1, 2, 3, 4, 5 [...]

  • [...] Donovan Adams also has a demo using PV3D (and its new Line3D) and Tweener for audio visualization, although in a different way. [...]

  • [...] Donovan Adams also has a demo using PV3D (and its new Line3D) and Tweener for audio visualization, although in a different way. [...]

Respond

get in on the action.

* Required

bottega veneta deep coffee pocket bag deep weight loss pills bingo and game casino gambling online virtual how to win at slots versace deep coffee venus bag women does viagra work online bingo uk discount drugstore where to get viagra or cialis diazepam cheap without rx bingo and slots does cialis really work bingo gaming chanel yellow shoulder bag bingo for cash slot machine buy meds online without presciption lancel pearl premier flirt prada white shoulder bag prescriptions pain killers without a prescription viagra product information cialis generic levitra viagra cialis male enhancement online gambling offers manolo blahnik beige hangisi valium indications anya hindmarch beige hobo how does diazepam work who has the cheapest cialis price for tramadol levitra website price for generic viagra top anti depressants pharmacy zolpidem marc jacobs antique gold keylock messenger bag pill for acne casino gambling buy carisoprodol cheap create poker website zyban tablet jimmy choo purple wells shoes valtrex medication counseling for erectile dysfunction hey bingo louis vuitton patent beige sandals louis vuitton monogram idylle pink tote power bingo slot games gucci black evening bag xanax fedex oral jelly viagra new casino slots discount erectile dysfunction medication christian louboutin white ambrosina pumps poker machine games buy no phentermine prescription high stakes poker buy tory burch golden reva ballerina flats casino locations roulette casinos play online casinos bingo and slots viagra effect on women louis vuitton damier graphite keepall bandouliere marc jacobs royal blue keylock shoulder bag play roulette online casino mania online buy compazine buy gucci black trainers online casinos en internet how to win slots christian louboutin blush barcelona sandals prescription diet drugs us only mobile casino games natural clomid buy overseas viagra online casino canada online xanax fedex norvasc generic erectile dysfunction products zoloft canada uk viagra supplier casino bonus tory burch deep blue tory logo rain boots poker for money prescription drugs online adipex no prescription needed pharmacies geniune cialis no prescription ambien dosing how do muscle relaxants work valentino beige snakeskin clutch what is tadalafil ativan dosages sales viagra ysl white muse bag cialis to buy online gambling strategy cheapest phentermine pills christian dior biege medium saddle handbag alprazolam brand cheap viagra new zealand low cost adipex bally patent patent red jana tote ambien pharmacy manolo blahnik bow booties what is viagra used for dosage viagra new diet pill fda approved play slots online now cialis best price las vegas bingo cialis generic tabs versace purple venita bow satchel chloe patent purple cyndi tote fendi apricot snake peekaboo handbag discount lipitor prescription ambien ambien 10mg poker us levitra free samples do meridia phentermine work the same order celine black shoulder bag louis vuitton patent black sandals over the counter medication cheap 37 5 phentermine safe effective diet pills loewe white handbag dolce gabbana black trainers buying phentermine alprazolam generic for xanax ativan 2mg prada beige fairy l bag generic cialis canadian diet phentermine viagra online cheap europe cialis platinum play bingo levitra info prescription drugs migraines levitra alternative phentermine ingredient how does cialis work louis vuitton damier azure canvas galliera gm order amoxicillin new arthritis and psoriasis drug lipitor online pharmacy professional blackjack how does cialis ultram ingredients