package {
    import com.greensock.TweenLite;
    import com.greensock.easing.RoughEase;
    
    import flash.display.Sprite;
    import flash.events.MouseEvent;

    [SWF(width="600", height="400", frameRate="25", backgroundColor="#FFFFFF")]
    public class RoughTween extends Sprite
    {
        public function RoughTween()
        {
            
            for(var i:int = 0; i < 200; i++) {
                var radius:Number = 5 + (Math.random() * 30);
                var circle:Sprite = new Sprite();
                circle.graphics.beginFill(Math.random()*0xffffff, Math.random());
                circle.graphics.drawCircle(0, 0, radius);
                circle.graphics.endFill();
                this.addChild(circle);
                TweenLite.to(circle, Math.random(), {x:Math.random()*600, y:Math.random()*400});
                circle.addEventListener(MouseEvent.MOUSE_OVER, onCircleOver);
            }
        }
        
        private function onCircleOver(e:MouseEvent):void {
            var xx:Number = e.currentTarget.x;
            var yy:Number = e.currentTarget.y;
            e.currentTarget.x = xx + (-50 + (Math.random()*100));
            e.currentTarget.y = yy + (-50 + (Math.random()*100)); 
            TweenLite.to(e.currentTarget, 1, {x:xx, y:yy, ease:RoughEase.create(1, 20)});
        }
    }
}