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

hitTestObject 2 (add blur)

ARROW CURSOR to move
Get Adobe Flash player
by tananuka13 24 Dec 2010
/**
 * Copyright tananuka13 ( http://wonderfl.net/user/tananuka13 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/6egE
 */

// forked from gjigbhkzkb's forked from: forked from Vovan: gjigbhkzkb
// forked from tananuka13's forked from Vovan: gjigbhkzkb
// forked from gjigbhkzkb's gjigbhkzkb
package 
{
    import flash.filters.BlurFilter;
    import flash.geom.Point;
    import flash.geom.ColorTransform;
    import flash.display.ColorCorrection;
    import flash.filters.ColorMatrixFilter;
    import flash.display.BlendMode;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.events.Event;
    import flash.display.Sprite;
    import flash.events.KeyboardEvent;
    
    [SWF(width="400",heigth="400",backgroundColor="0xbbbbbb",frameRate=30)]
    
    public class gjigbhkzkb extends Sprite 
    {
        private var po1:Pol;
        
        private var door:Sprite;
        private var o:Sprite;
        private const SPEED:uint = 5
        private const KOL_POL:uint = 12
        private var o_speed_x:Number = 0
        private var o_speed_y:Number = 0
         
        private var polArr:Array = new Array()
        
        private var bm:BitmapData // render
        private var bm_effect:BitmapData = new BitmapData(500,500, false, 0x000000)
        
        public static var globalClass:Sprite
       
        public function gjigbhkzkb() 
        {
           globalClass = this 
           this.stage.frameRate = 60
           // render
           bm = new BitmapData(500,500, false, 0x000000)
           this.addChild( new Bitmap(bm) )
           // end render
            this.stage.addEventListener(KeyboardEvent.KEY_DOWN, dvizenie);
            this.stage.addEventListener(KeyboardEvent.KEY_UP, noDvizenie);
            this.stage.addEventListener(Event.ENTER_FRAME, update)
           // for 
            
        for (var i:int = 0;  i < KOL_POL;  i++) //i = i +1
         {
             po1 = new Pol();
              polArr.push(po1)
             
         }
          
          
        /*.door = new Sprite();  
        //door.graphics.lineStyle(1, 0x000000);
        door.graphics.beginFill(0x339933)
        door.graphics.drawRect(0, 0, 30, 50);
        door.graphics.endFill();
        door.x = 100;
        door.y = 50;
        this.addChild(door);*/
        
        
        
        this.o = new Sprite();  
        //o.graphics.lineStyle(1, 0x000000);
        o.graphics.beginFill(0xbb9933)
        o.graphics.drawCircle(10, 10, 10);
        o.graphics.endFill();
        o.x = 380;
        o.y = 430;
        this.addChild(o);
        
          
          
            
        }
        
         public function update(e:Event):void 
         { 
             // move
             this.o.x = this.o.x  +  o_speed_x
             this.o.y += o_speed_y 
           
             // udar
             var kol:int = polArr.length
             var udar:Boolean
             for (var i:int = 0;  i < kol;  i++) //i = i +1
             {
                po1 = polArr[i]
                udar = this.o.hitTestObject(po1) // проверка столкновения
                //po1.rotation += po1.speed_rotation //
                if ( udar ) 
                {
                    this.stop(po1)
                   // break;
                }
             }
             
            // render
            bm.lock()
            var scale:Number = 0.1 // 
            bm_effect.draw(this, null, new ColorTransform(scale, scale, scale, scale) , BlendMode.ADD)
            var  merge:uint = 0x10  
            bm.draw(this)
            bm.applyFilter( bm, bm.rect, new Point(), new BlurFilter(1.5, 1.5) )
            bm.merge(bm_effect, bm_effect.rect, new Point(), merge,merge,merge,merge)
            bm.unlock()
             

         
         }
         
         public function stop(po:Pol):void {
             
            // var farX:Number = po.x - this.o.x 
            // var farY:Number = po.y - this.o.y
            // o_speed_x = farX / Math.abs(farX)// * 10
            // o_speed_y = farY / Math.abs(farY) //* 10
             //var angle:Number = 
              
             this.o.x -= o_speed_x*2
             this.o.y -= o_speed_y*2
         }
        
        public function dvizenie(e:KeyboardEvent):void {               
           if (e.keyCode == 39){
              o_speed_x = SPEED
              o_speed_y = 0//SPEED
              
           }
           if ( e.keyCode == 37){
               o_speed_x = -SPEED
              o_speed_y = 0//SPEED
           }
           if ( e.keyCode == 40){
                o_speed_x = 0//SPEED
              o_speed_y = SPEED
           }
           if ( e.keyCode == 38){
                o_speed_x = 0//SPEED
              o_speed_y = -SPEED
           }  
            
        }
        
        public function noDvizenie(e:KeyboardEvent):void {               
              o_speed_x = 0
              o_speed_y = 0//SPEED 
        }  
                      
    }
}
import flash.display.BitmapData;
import flash.display.Bitmap;



import flash.display.Sprite;

class Pol extends Sprite {
    
    private const STENA_HEIGHT:uint = 5
    private const STENA_WIDTH:uint = 100
    
    public var speed_rotation:Number
    
    function Pol() {
        speed_rotation = 3 + Math.random()*5
        this.x = 100 + Math.random()*400
        this.y = 200 + Math.random()*150
        //this.graphics.lineStyle(1, 0x336699);
        this.graphics.beginFill(0x993333, 0.5)
        this.graphics.drawRect(-STENA_WIDTH/2, -STENA_HEIGHT/2, STENA_WIDTH, STENA_HEIGHT);
         this.graphics.drawRect(-STENA_HEIGHT/2, -STENA_WIDTH/2, STENA_HEIGHT, STENA_WIDTH);  
        this.graphics.endFill();
        this.cacheAsBitmap = true
        this.mouseEnabled = false
        var fon_pol:Bitmap =  new  Bitmap(new BitmapData(STENA_WIDTH,STENA_WIDTH, true, 0x10336699))
        fon_pol.x = this.x - STENA_WIDTH/2
        fon_pol.y = this.y - STENA_WIDTH/2
        gjigbhkzkb.globalClass.addChild(fon_pol);
        gjigbhkzkb.globalClass.addChild(this);
    }

}