title: How to implement enemy behaviour based on type?
body: <p>I am building a game which create three types of enemy.Amount them only type 3 can fire others cannt.This is my enemy class</p>
  
  <pre><code>package 
  {
      import flash.display.MovieClip;
      import flash.utils.getTimer;
      import flash.events.Event;
      import flash.utils.Timer;
      import flash.events.TimerEvent;
      import flash.geom.Point;
  
  
  public class Enemy extends MovieClip
  {
      private var lastTime:int;
      var hitCounter:Number = 1;
      public var eType:Number = 0;
      private var startYpos:Number = 0;
  
      var nextFire:Timer;
      var enemyType:Number;
  
      public var bullets:Array = new Array  ;
  
      var speedY:Number = 50;
      var enemySpeed:Number = 50;
  
      var firstPos:Number = 0;
      var fireCounter:Number = 0;
      var firePause:Number = 10;
  
      public function Enemy(xPos,yPos:Number,t:Number)
      {
          // constructor code
          this.x = xPos;
          firstPos = this.y = yPos;
          this.enemyType = t;
          lastTime = getTimer();
          this.gotoAndStop(t);
  
          addEventListener(Event.ENTER_FRAME,moveEnemy);
      }
  
      public function moveEnemy(event:Event)
      {
          // get time passed
          var timePassed:int = getTimer() - lastTime;
          lastTime +=  timePassed;
          // move bullet
  
          if (this.y + this.height / 2 &gt; firstPos + 100 &amp;&amp; speedY &gt; 0)
          {
              speedY *=  -1;
  
          }
  
          if (this.y - this.height / 2 &lt; firstPos &amp;&amp; speedY &lt; 0)
          {
              speedY *=  -1;
          }
  
          this.x -=  enemySpeed * timePassed / 1000;
          this.y +=  speedY * timePassed / 1000;
  
          // bullet past top of screen
          if (this.x - this.width / 2 &lt; 0)
          {
              deleteEnemy();
          }
  
          if (this.enemyType == 3)
          {
              canFire();
          }
      }
  
      public function canFire()
      {
          if ((fireCounter &gt; firePause))
          {
              MovieClip(parent).createEnemyBullet();
              trace((('Enemy Type : ' + enemyType) + ' and firing'));
              fireCounter = 0;
          }
          else
          {
  
              fireCounter++;
          }
      }
  
      public function deleteEnemy()
      {
          if (this.currentFrame == 2)
          {
              this.gotoAndStop(4);
          }
          else
          {
  
              //trace(MovieClip(parent).enemyKilled[this.enemyType-1]);
              MovieClip(parent).enemyKilled[this.enemyType - 1]++;
              MovieClip(parent).removeEnemy(this);
              parent.removeChild(this);
              removeEventListener(Event.ENTER_FRAME,moveEnemy);
          }
      }
    }
  }
  </code></pre>
  
  <p>Now once a enemy type 3 start firing then every enemy start firing.i want just only enemy type 3 can fire not other enemy.How i do it?
  Thanks in advance</p>
  
  <p><strong>Addition :</strong> </p>
  
  <pre><code>public function createEnemyBullet()
      {           
          var bullet:Bullet = new Bullet(enemy.x - 10,enemy.y,500,-1);
          bullets.push(bullet);
          addChild(bullet);       
  
          //setEnemyBullet();
      }
  </code></pre>