package classes.matuto.midia.som.soundMixer
{
	
	
	import classes.caurina.transitions.Tweener;
	import classes.fl.transitions.easing.Strong;
	import classes.greensock.TweenLite;
	import classes.matuto.utils.model.MathG;
	
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.filters.BlurFilter;
	import flash.geom.ColorTransform;
	import flash.media.Sound;
	import flash.media.SoundChannel;
	import flash.media.SoundLoaderContext;
	import flash.media.SoundMixer;
	import flash.net.URLRequest;
	import flash.utils.ByteArray;
	
	
	public class MTSoundMixer extends Sprite
	{
		
		
		private var type			:String;
		private var container		:MovieClip;
		
		private var RENDER			:Function;
		
		private var onRender			:Function;
		
		public function MTSoundMixer(_type:String,_container:MovieClip,_onRender:Function)
		{
			container = _container;
			type      = _type;
			onRender  = _onRender;
			
		    addEventListener(Event.ENTER_FRAME,getRENDER());	
		}
		
		private function RENDER_X_Y_Z(e:Event=null):void
		{
			var byte:ByteArray 		= new ByteArray();
			SoundMixer.computeSpectrum(byte, false, 0);
		
			var i		:int;
			var item	:MovieClip;
			
			for (i = 0; i < container.numChildren; i++) 
			{	
				item  			= container.getChildAt(i) as MovieClip;
				var rl:Number   = byte.readFloat();
			
				onRender(item,rl);
			}	
		}
		
		public function getRENDER():Function
		{	
			switch(type)
			{
				
				case  SoundMixerType.SCALE_X_Y_Z:
					RENDER = RENDER_X_Y_Z;					
				break;
				
			}	
			
			return RENDER;
		}
		
		
		//mixer   = new MTSoundMixer(SoundMixerType.SCALE_X_Y_Z,movie,mixerRender);
		
		/*
		
		private function mixerRender(item:MovieClip,rl:Number):void
		{
			var aux:int = Math.round(Math.random()*1);
			
			if(aux==0)
			Tweener.addTween(item,{time:.8,z:rl * 300,transition:"linear"});
			else
			Tweener.addTween(item._l,{time:1,scaleY:rl * 10,delay:0,transition:"linear"});	
		}
		
		*/
		

		
	}//end class
}

