flash on 2010-4-4

by lewis_c1986
♥0 | Line 40 | Modified 2010-04-04 03:17:36 | MIT License
play

ActionScript3 source code

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

package {
    import flash.display.Sprite;
    import flash.geom.Rectangle;
       
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.MouseEvent;
	import flash.events.KeyboardEvent;
	
    public class FlashTest extends Sprite
    {
    		private var activeElement:Sprite;
    	    public function FlashTest()
        {
            // write as3 code here..
            var sprite1:Box = Box(0x0099ff,100,100,0,0);
			this.addChild(sprite1);
			var sprite2:Box = Box(0x000000,100,100,200,200);
			this.addChild(sprite2);
			sprite1.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
			sprite1.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
		}
        private function startDragging(evt:MouseEvent):void
        {
        		startDrag(evt.target);
        }
        private function stopDragging(evt:MouseEvent):void
        {
        		stopDrag();
        }
    }
    public class Box extends Sprite
    {
    		public function Box(_color:uint, _width:uint, _height:uint, _x:uint, _y:uint)
    		{
			var box:Sprite = new Sprite();
			box.graphics.beginFill(_color);
			box.graphics.drawRect(_x-(_width/2), _y-(_height/2), _width, _height);
			box.graphics.endFill();
			box.alpha = 100;
    		}
    }
}