Ver Mensaje Individual
  #1 (permalink)  
Antiguo 24/05/2010, 20:05
Avatar de caste_88
caste_88
 
Fecha de Ingreso: abril-2006
Mensajes: 16
Antigüedad: 18 años
Puntos: 0
problema de fondo flash AS3

buenas noches, tengo un problemita que no puedo resolver..
me baje un script que simula unos bokeh en movimiento..
un bokeh es una tecnica fotografia que resulta en [URL="http://www.google.com.ar/images?hl=es&q=bokeh&um=1&ie=UTF-8&source=og&sa=N&tab=wi"]ESTO[/URL]

esta barbaro, y me re sirve, pero el tema es que no puedo quitarle el fondo para ponerle una imagen detras
como se genera por AS3 ando medio perdido..
lo que necesitaria es quitar el "fondo" negro para que queden solo las esferas flotando encima de una imagen...

dejo los archivos [URL="http://www.mediafire.com/?3nujkolimot"]ACA[/URL]

y el codigo por si alguien puede ayudarme..

Código:
/*---------------------------------------------------------------------------------------------

	[AS3]
	=======================================================================================
	(c) 2008 Tomek Augustyn aka Og2t, http://play.blog2t.net/
	
	VERSION HISTORY:
	v0.1	2010/04/29	A star was born.

	USAGE:

	TODOs:

	DEV IDEAS:

	KNOWN ISSUES:

---------------------------------------------------------------------------------------------*/

package 
{
	// IMPORTS ////////////////////////////////////////////////////////////////////////////////

	import flash.display.Sprite;
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Bitmap;

	import flash.events.Event;
	
	import flash.geom.Point;
	import flash.geom.Matrix;
	import flash.geom.ColorTransform;
	
	// CLASS //////////////////////////////////////////////////////////////////////////////////

	public class BokehDemo extends Sprite
	{
		// CONSTANTS //////////////////////////////////////////////////////////////////////////
		
		private static const MAX_BLOBS:int = 30;
		
		// MEMBERS ////////////////////////////////////////////////////////////////////////////
		
		private var blob:Blob;
		private var blobs:Array = [];
		private var blobHolder:Sprite;
		
		private var bmpData:BitmapData = new BitmapData(1000, 1000, true, 0x000000);
		private var matrix:Matrix = new Matrix();
		
		// CONSTRUCTOR ////////////////////////////////////////////////////////////////////////
		
		public function BokehDemo()
		{
			var bitmap:Bitmap = new Bitmap(bmpData);
			addChild(bitmap);
			
			addChild(gradientMC);
			gradientMC.alpha = 1;
			
			for (var i:int = 0; i < 5; i++) addBlob();
			
			addEventListener(Event.ENTER_FRAME, frameLoop);	
		}
		
		// PUBLIC METHODS /////////////////////////////////////////////////////////////////////
		
		// PRIVATE METHODS ////////////////////////////////////////////////////////////////////
		
		private function addBlob():void
		{
			blob = new Blob();
			
			blob.destX = blob.x = Math.random() * 440;
			blob.destY = blob.y = Math.random() * 300;
			blob.velX = randRange(-1, 1);
			blob.velY = randRange(-1, 1);
			blob.velAlpha = Math.random() * 0.03;
			blob.growth = Math.random() * 0.005;
			blob.destScale = Math.random() * 0.75 + 0.25;
			blob.life = 60 + int(Math.random() * 50);
			blob.add(BallSphere);
			
			blobs.push(blob);
		}
		
		// EVENT HANDLERS /////////////////////////////////////////////////////////////////////

		private function frameLoop(event:Event):void
		{		
			for (var i:int = 0; i < blobs.length; i++)
			{	
				blob = blobs[i];
				
				if (blob.life == 10) blob.velAlpha *= -1;
				
				if (blob.alpha < 0)
				{
					blobs.splice(i, 1);
					blob.destroy();
				}
				
				blob.life--;
			}
			
			if (Math.random() * 100 > 92) addBlob();
			
			bmpData.fillRect(bmpData.rect, 0x000000);
			
			for each (var blob:Blob in blobs)
			{
				blob.update();
				matrix.identity();
				matrix.scale(blob.destScale, blob.destScale);
				matrix.translate(blob.x, blob.y);
				bmpData.draw(blob, matrix, new ColorTransform(1.0, 1.0, 1.0, blob.alpha, 0, 0, 0, 0), "add");
			}
		}
		
		// GETTERS & SETTERS //////////////////////////////////////////////////////////////////
		// HELPERS ////////////////////////////////////////////////////////////////////////////

		private function randRange(min:Number, max:Number):Number
		{
			return Math.random()*(max-min)+min; 
		}	
	}
}

import flash.display.Sprite;
import flash.display.MovieClip;

class Blob extends Sprite
{
	public var blobInstance:MovieClip;
	public var destX:Number; 
	public var destY:Number; 
	public var destAlpha:Number = 0;
	public var destScale:Number = 0;
	public var velX:Number = 0; 
	public var velY:Number = 0;
	public var velAlpha:Number = 0;
	public var growth:Number = 0;
	public var life:int = 0;
	
	public function add(blobClass:Class):void
	{
		blobInstance = new blobClass();
		blobInstance.gotoAndStop(int(Math.random() * 25));
		addChild(blobInstance);
		scaleX = scaleY = destScale;
		alpha = destAlpha = 0;
	}
	
	public function update():void
	{
		destX += velX; 
		destY += velY; 
		
		destScale += growth;
		destAlpha += velAlpha;
		
		scaleX += (destScale - scaleX) / 3;
		scaleY = scaleX;
		
		x += (destX - x) / 3;
		y += (destY - y) / 3;
		alpha += (destAlpha - alpha) / 3;
	}
	
	public function destroy():void
	{
		blobInstance.parent.removeChild(blobInstance);
		blobInstance = null;
	}
}
Saludos