package  
{
    import flash.display.MovieClip;
    import flash.events.Event;
	public class brickshooter extends MovieClip
	{
		var directionRight:Boolean = true;
		var counter:int = 0;
		var chosenY:Number = 0;
		public static var instance:brickshooter;
		
		public function brickshooter(dir:Boolean, posX:Number, posY:Number) 
		{
			if(dir)
			{
				x = posX;
			}else
			{
				x = posX + 16;
			}
			y = posY;
			chosenY = posY;
			directionRight = dir;
            addEventListener(Event.ENTER_FRAME, loop);
		}
		public function loop(e:Event):void 
		{
			counter++;
			if(directionRight)
			{
				scaleX = 1;
			}else
			{
				scaleX = -1;
			}
			if(counter > 150 && !MovieClip(root).dead && !MovieClip(root).win)
			{
				//var bullet:spikebullet = new spikebullet(directionRight, x+16*scaleX, y-chosenY, stepspeed);
    			//addChild(bullet);
				MovieClip(root).shootBrickArrow(directionRight, x+16*scaleX, chosenY);
				counter = 0;
			}
		}
		public function destroy():void 
		{
			removeEventListener(Event.ENTER_FRAME, loop);
			this.parent.removeChild(this);
		}
	}
	
}
