In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

Estrellas Brillantes

...
@author Obed Santos
package {
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.BlendMode;
import flash.display.MovieClip;
import flash.events.Event;
import flash.geom.ColorTransform;
import flash.geom.Matrix;
import flash.geom.Rectangle;
import flash.utils.Dictionary;
import flash.display.PixelSnapping;

import net.hires.debug.Stats;


/**
 * ...
 * @author Obed Santos
 */
public class main extends MovieClip{
	
	public const MAXIMA_CANT_PIXELS:uint = 450;
	
	public var bmpD:BitmapData;
	public var bmp:Bitmap;
	public var matricita:Matrix;
	public var listapixelitos:Dictionary;
	private var cantidad_actual_pix:uint = 0;
	public var ancho_total:uint;
	public var alto_total:uint;
	private var color_fondo_total:uint = 0x000000;
	
	public var bmpD2:BitmapData;
	public var bmpSegundo:Bitmap;
	
	public var bmpD3:BitmapData;
	private var bmpTercero:Bitmap;
	private var matricita_tres:Matrix;

	public function main() {

		ancho_total = stage.stageWidth;
		alto_total = stage.stageHeight;
		
		bmpD = new BitmapData(ancho_total, alto_total, false, color_fondo_total);
		bmp = new Bitmap(bmpD);
		addChild(bmp);
		
		bmpD2 = new BitmapData(ancho_total / 4, alto_total / 4, false, color_fondo_total);
		bmpSegundo = new Bitmap(bmpD2, PixelSnapping.NEVER, true);

		bmpSegundo.scaleX = bmpSegundo.scaleY = 4;
		bmpSegundo.blendMode = BlendMode.ADD;
		
		matricita = new Matrix(.25, 0, 0, .25);
		addChild(bmpSegundo);
		
		bmpD3 = new BitmapData(ancho_total / 8, alto_total / 8, false, color_fondo_total);
		//bmpD3.colorTransform(bmpD3.rect, new ColorTransform(1,1,1,1,140));
		bmpTercero = new Bitmap(bmpD3, PixelSnapping.NEVER, true);
		bmpTercero.scaleX = bmpTercero.scaleY = 8;
		bmpTercero.blendMode = BlendMode.ADD;
		
		
		matricita_tres = new Matrix(.125, 0, 0, .125);
		//var ann:Number = 40 * Math.PI / 180;
		//matricita_tres.concat(new Matrix(Math.cos(ann), Math.sin(ann), -Math.sin(ann), Math.cos(ann)));
		
		addChild(bmpTercero);
		
		listapixelitos = new Dictionary();
		addEventListener(Event.ENTER_FRAME, on_enter_frame);

                 addChild(new Stats());
	}
	
	private function on_enter_frame(e:Event):void {
		bmpD.lock();
		render_background();
		render_pixelitos();
		add_pixelitos();
		render_brillo();
		bmpD.unlock();
	}
	
	private function render_brillo():void{
		bmpD2.draw(bmpD, matricita);
		bmpD3.draw(bmpD, matricita_tres);
	}
	
	private function add_pixelitos():void {
		if (cantidad_actual_pix < MAXIMA_CANT_PIXELS) {
			//var pixelillo:pixelito = new pixelito(ancho_total/2,alto_total/2, 0xFFFFFFFF);
			var pixelillo:pixelito = new pixelito(mouseX, mouseY, Math.random() * 0xFFFFFFFF);
			pixelillo.pintar(bmpD);
			listapixelitos[pixelillo] = true;
			cantidad_actual_pix++;
		}
	}
    private function render_pixelitos():void{
    for (var k:* in listapixelitos) {
	var temp_pixelito:pixelito = pixelito(k);
	temp_pixelito.mover_y_pintar(bmpD);
	if (temp_pixelito.ypos > alto_total || temp_pixelito.ypos < 0 || temp_pixelito.xpos > ancho_total || temp_pixelito.xpos < 0) {
				delete listapixelitos[k];
				cantidad_actual_pix--;
			}				
		}
	}
	
	private function render_background():void{
		bmpD.fillRect(bmpD.rect, color_fondo_total);
	}
	
}


}

import flash.display.BitmapData;

	class pixelito {
		
		public var ypos:Number;
		public var xpos:Number;
		public var color:uint;
		private var direccion:Number;
		
		public function pixelito(x:int, y:int, col:uint):void {
			ypos = y;
			xpos = x;
			color = col;
			direccion = (Math.random() * 360) * Math.PI / 180;
		}
		
		public function mover_y_pintar(_bmp:BitmapData):void {
			this.xpos += Math.cos(direccion);
			this.ypos += Math.sin(direccion);
			pintar(_bmp);
		}
		
		public function pintar(_bmp:BitmapData):void{
			_bmp.setPixel(xpos, ypos, color);
		}
		
	}