title: Actionscript 3: sounds in Movieclip timeline cut each other off
body: <p>I'm having a weird problem with sounds interrupting each other in an AS3 game. </p>
  
  <p>Each enemy in the game world has a movieclip containing its graphics and sounds; game code calls gotoAndPlay() to play a particular animation with corresponding sound. (the movieclips are made in Flash and the .swc is imported into a Flashdevelop project)</p>
  
  <p>The problem is that when more than one instance of a particular type of enemy is onscreen at the same time, their sounds "stomp" on each other: if enemies A and B are of the same type, and A is in the middle of playing a sound, B won't be able to play that sound -- gotoAndPlay results in correct animation, but the sound doesn't play. </p>
  
  <p>Similarly, if A is playing a looping sound and B plays a frame containing a stop-sound event, it will stop A's loop.</p>
  
  <p>It seems pretty clear that what's happening is the Flashplayer is only allocating a single channel per movieclip <em>type</em>, rather than per movieclip instance, however google isn't really showing me anything.</p>
  
  <p>Are there best practices for this scenario? (i.e multiple instances of the same movieclip which has sound+animation on its timeline) What am I doing wrong?!</p>
  
  <p>Thanks for your time.</p>
  
  <p>[edit] </p>
  
  <p>To explain a bit better what I mean, let's say there's a Baddie movieclip which contains several animations, e.g the enemy running, crouching, jumping, firing a gun.</p>
  
  <p>There are two layers in the movieclip, one for graphics (animation), one for sound.</p>
  
  <p>On frame 20 there's a muzzleflash (on the animation layer) and a corresponding gun-shot sound (on the sound layer); on frame 40 there's a jump animation and corresponding jump sound.</p>
  
  <p>My problem is: if there are two or more of these movieclips on the stage at once, and one of them is in the middle of playing the gun-shot sound, the others won't play the gun-shot sound (they'll still animate correctly though). </p>
  
  <p>It seems like the Flashplayer is only allocating a single audio channel for <em>all</em> instances of a certain movieclip. This seems like it can't be expected behaviour since it would be useless, so I'm guessing I've messed something up with embedding (maybe there's a parameter or flag hidden somewhere which lets me say "give each instance its own sound channel"?)</p>