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

Going Nowhere

Get Adobe Flash player
by Quasimondo 22 Feb 2011

    Talk

    Thy at 22 Feb 2011 06:19
    protein
    Thy at 22 Feb 2011 06:19
    space invaders

    Tags

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

package {
    import flash.utils.setTimeout;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.Sprite;
    
    // A useless sketch which resulted from trying to implement
    //http://en.wikipedia.org/wiki/Tupper%27s_self-referential_formula
    
    public class CharFromUint extends Sprite 
    {
        
        private var map:BitmapData;
        private var ox:int;
        private var oy:int;
        private var c:uint;
        
        public function CharFromUint() 
        {
             map = new BitmapData( 20 * 7, 20 * 8, false, 0 )
             var b:Bitmap = addChild( new Bitmap( map ) ) as Bitmap;
             b.scaleX = b.scaleY = 3;
             c = 0;
             ox = 0;
             oy = 0;
             update()
        }
        
        private function update():void
        {
           map.lock();
           render( c );
           render( c | ( 1 << 30 ));  
           render( c | ( 2 << 30 ));  
           render( c | ( 3 << 30 ));  
           c++;
           
           map.unlock();
           setTimeout(update, 10 ); 
        }

        
        private function render( n:uint ):void
        {
               
               var i:int = 30;
               var c:int = 0;
               while ( --i > -1 )
               {
                      map.setPixel(ox + i % 5, oy + i / 5, c = 0xffffff * (( n >>> i ) & 1));
                      if ( (n >> 30) & 1 )  map.setPixel(ox + 5 - (i % 5) -1, oy + i / 5, c );
                      if ( (n >> 31) & 1 )  map.setPixel(ox +(i % 5), oy + 6 - i / 5 - 1, c );
               }
             
              
              ox += 7;
              if ( ox == map.width )
              {
                ox = 0;
                oy += 8;
                if ( oy == map.height )
                {
                   oy = 0;
                }
            }
         }

    }
}