title: ActionScript 3 - Initiating A Bullet Changes Direction With Character
body: <p>I'm working on a side scroller that has a character that fires a bullet every time you hit spacebar, the problem I'm having is moving the bullet in the direction the character is facing (left or right).</p>
  
  <p>I have a few of boolean variables to tell me which direction my character is facing: walkingRight | walkingLeft, so if my walkingRight == true, I want the bullet to travel +=10, and walkingLeft == true, bullet -= 10.</p>
  
  <p>The problem is, when I fire facing left, the bullet moves left, but as soon as I turn right, that same bullets starts moving right.</p>
  
  <p>Here is a snippet of AS3 code (Every Frame):</p>
  
  <pre><code>if(gamepad.fire2.isPressed){
     // initiate bullet
     var bullet = new Bullet();
     bullet.x = _player.x;
     bullet.y = _player.y;
     /*_boundaries.*/addChild(bullet);
     bullets.push(bullet);
  }
  
  for each(var bullet in bullets){
     if(walkingRight || idleRight || jumpingRight){
      bullet.x += 10;
      trace("Bullet - Moving Right");
     }
     else if(walkingLeft || idleLeft || jumpingLeft){
      bullet.x -= 10;
      trace("Bullet - Moving Left");
     }
  }
  </code></pre>
  
  <p>I sure would appreciate any help from this as its for a college project.</p>
  
  <p>Thanks</p>