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

Rocket Skittles

Mario Gonzalez
mario@wddg.com
http://onedayitwillmake.com


Can someone figure out why putting the mouse on the top left
causes glitches?
Get Adobe Flash player
by onedayitwillmake 07 May 2009
  • Related works: 1
  • Talk

    bradsedito at 06 Mar 2011 23:27
    Glitches caused by something that has to do with the upper left point being the default registration point in AS3. Idk man, been trying to solve that mind f*** for years hahaha

    Tags

    Embed
/**
 * Copyright onedayitwillmake ( http://wonderfl.net/user/onedayitwillmake )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/yvxs
 */

/**
Mario Gonzalez
mario@wddg.com
http://onedayitwillmake.com


Can someone figure out why putting the mouse on the top left
causes glitches?
*/
package
{
		
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.GradientType;
    import flash.display.SpreadMethod;
    import flash.display.Sprite;
    import flash.display.StageQuality;
    import flash.events.Event;
    import flash.events.TimerEvent;
    import flash.filters.BitmapFilter;
    import flash.filters.BlurFilter;
    import flash.geom.Matrix;
    import flash.geom.Point;
    import flash.utils.Timer;
	
	[SWF(frameRate="60", width="465", height="465", backgroundColor="#000000")]
	
    public class wonderfl extends Sprite 
    {
	    private var _view :Sprite;
	    private var _canvas:BitmapData ;
	    
	    public function wonderfl():void
	    {       
	        stage.quality = StageQuality.LOW;
	        _canvas = new BitmapData(465,465, true, 0x00000000);
	        _view = new Sprite();
	        addChild(_view);
	         
	        addChild(new Bitmap(_canvas));
	        
	        for(var i:int = 0; i < 150; i++)
	        {
	            _view.addChild(new Velocity());
	               
	        }
			createBG()
			addEventListener(Event.ENTER_FRAME, draw);
	    }
	    
		private function createBG():void 
		{
			var matr:Matrix = new Matrix();
			matr.createGradientBox(465, 465, Math.PI / 2, 0, 0);
			
			var bg:Sprite = new Sprite();
			bg.graphics.beginGradientFill
			(
				GradientType.LINEAR, 
				[0x002B5E, 0x000000], //colors
				[1, 1], //alphas
				[0, 255], //ratios
				matr, //matrix
				SpreadMethod.PAD
			);	
			
			bg.graphics.drawRect(0, 0, 465, 465);
			bg.graphics.endFill();
			
			bg.graphics.beginFill(0xffffff, Math.random() * 0.5);
			for(var i:int = 0; i<20; i++)
				bg.graphics.drawCircle(Math.random() * 465, Math.random() * 232, Math.random() * 4);
			bg.graphics.endFill();
							
			addChildAt(bg, 0);
		}
	
		private var blur:BitmapFilter = new BlurFilter(16,16,1);
		private var op:Point = new Point(0,0);
		private function draw(e:Event):void
		{ 
		    _canvas.draw(_view);
		    _canvas.applyFilter( _canvas, _canvas.rect, op, blur );
		    _canvas.scroll( Math.random()*10 + 2, 16);
		}
	}
}


import flash.display.Sprite;
import flash.events.Event;
import flash.events.TimerEvent;
import flash.utils.Timer;
import flash.display.BlendMode;
    
class Velocity extends Sprite
{
	private var _sprite			:Sprite;
	private var _easing			:Number= 0.94 + Math.random() * 0.04
	private var _vx				:Number = 0//Math.random() * 20;            
	private var _vy				:Number = 0;
	private var _k				:Number= Math.random() * 0.83;
	private var _damp			:Number= 0.91
	private var _timer			:Timer;  
			
   public function Velocity()
   {
		_sprite=new Sprite(); 
		
		var chance:Number = Math.random();
		  
		(Math.random() < 0.15) ? _sprite.blendMode = BlendMode.ADD : _sprite.blendMode = BlendMode.OVERLAY	 
		 
		_sprite.graphics.beginFill(Math.random() * 255 * 255 * 255, Math.random() * 0.8 + 0.1);
		_sprite.graphics.drawCircle(0,0, Math.random() * 15);
		_sprite.graphics.endFill();
		_sprite.x= 232;
		_sprite.y= 465;
		  
		
		 addChild(_sprite);
		 _timer = new Timer(20);
		 _timer.addEventListener("timer",onTimer);
		 _timer.start(); 
	}
			
    public function onTimer(event:TimerEvent):void
    {
		var mx:Number, my:Number
		
		//Random area in the middle, if the user hasn't used their mouse yet
		if(mouseX == 0 || mouseY == 0)
		{
			mx = 232 + Math.random() * 150 - 75;
			my = 232 + Math.random() * 25 - 12.5;
		}
		else
		{
			mx = mouseX
			my = mouseY
		}
		
		var ax:Number = (mx - _sprite.x)*_k;
		var ay:Number = (my - _sprite.y)*_k;
		
		_vx += ax * _easing;
		_vy += ay * _easing;
		
		_sprite.x += _vx;
		_sprite.y += _vy;   
		
        _vx *= _damp;
		_vy *= _damp;
		
		if(Math.random() > 0.8)
			parent.setChildIndex(this, int(Math.random() * parent.numChildren));
	}
}